Allow missing name/args in FunctionCallData (all fields optional per Vertex schema) #12

Closed
opened 2026-10-26 18:21:24 +00:00 by andreban · 0 comments
Owner

Summary

FunctionCallData in src/types/common.rs requires both fields:

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FunctionCallData {
    pub name: String,
    pub args: Value,
}

The Vertex AI v1 schema (GoogleCloudAiplatformV1FunctionCall, discovery revision 20261012) documents every field as optional:

Field Type Docs
id string Optional. Unique id of the call; the response should carry the matching id (see #11).
name string Optional. Matches FunctionDeclaration.name.
args object Optional. Function parameters as a JSON object.
partialArgs array Optional. Incrementally streamed argument values.
willContinue boolean Optional. If true, another partial message for this call follows.

Impact

Any functionCall part without args or name fails to deserialize, which fails the whole response or stream chunk. Verified with serde:

  • {"name":"f"} → missing field args``
  • {"partialArgs":[],"willContinue":true} → missing field name``

This can hit zero-argument function calls (if the API omits args) and streamed function-call arguments.

Proposed fix

  • Add #[serde(default)] to args (or make it Option<Value>) so a missing args deserializes instead of erroring.
  • Decide how to handle name: Option<String> matches the schema, but is a breaking change for callers. #[serde(default)] keeps the type but yields an empty name for partial chunks.
  • Optionally add partial_args and will_continue (with skip_serializing_if) to support streamed function-call arguments.
## Summary `FunctionCallData` in `src/types/common.rs` requires both fields: ```rust #[derive(Clone, Debug, Serialize, Deserialize)] pub struct FunctionCallData { pub name: String, pub args: Value, } ``` The Vertex AI v1 schema (`GoogleCloudAiplatformV1FunctionCall`, discovery revision 20261012) documents every field as optional: | Field | Type | Docs | |---|---|---| | `id` | string | Optional. Unique id of the call; the response should carry the matching `id` (see #11). | | `name` | string | Optional. Matches `FunctionDeclaration.name`. | | `args` | object | Optional. Function parameters as a JSON object. | | `partialArgs` | array | Optional. Incrementally streamed argument values. | | `willContinue` | boolean | Optional. If true, another partial message for this call follows. | ## Impact Any `functionCall` part without `args` or `name` fails to deserialize, which fails the whole response or stream chunk. Verified with serde: - `{"name":"f"}` → `missing field `args`` - `{"partialArgs":[],"willContinue":true}` → `missing field `name`` This can hit zero-argument function calls (if the API omits `args`) and streamed function-call arguments. ## Proposed fix - Add `#[serde(default)]` to `args` (or make it `Option<Value>`) so a missing `args` deserializes instead of erroring. - Decide how to handle `name`: `Option<String>` matches the schema, but is a breaking change for callers. `#[serde(default)]` keeps the type but yields an empty name for partial chunks. - Optionally add `partial_args` and `will_continue` (with `skip_serializing_if`) to support streamed function-call arguments.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: andreban/gemini-rs#12