yc1838 commited on
Commit
8a34f60
·
1 Parent(s): fc230e2

fix: preserve gemini thought_signatures required for tool calls

Browse files
src/lilith_agent/app.py CHANGED
@@ -76,9 +76,6 @@ _RESPONSE_METADATA_NOISE_KEYS = frozenset({
76
  "safety_settings",
77
  "logprobs",
78
  "prompt_logprobs",
79
- "thought_signature",
80
- "thought_signatures",
81
- "__gemini_function_call_thought_signatures__",
82
  })
83
 
84
 
@@ -538,8 +535,9 @@ def build_react_agent(cfg: Config):
538
  response = model.invoke(prompt_msgs)
539
 
540
  # Clean up Gemini signatures and unhelpful metadata to reduce log noise and context bloat
 
 
541
  if hasattr(response, "additional_kwargs"):
542
- response.additional_kwargs.pop("__gemini_function_call_thought_signatures__", None)
543
  # Remove function_call duplicate if it exists in additional_kwargs (redundant with tool_calls)
544
  response.additional_kwargs.pop("function_call", None)
545
 
 
76
  "safety_settings",
77
  "logprobs",
78
  "prompt_logprobs",
 
 
 
79
  })
80
 
81
 
 
535
  response = model.invoke(prompt_msgs)
536
 
537
  # Clean up Gemini signatures and unhelpful metadata to reduce log noise and context bloat
538
+ # Note: Do not pop thought_signature or __gemini_function_call_thought_signatures__
539
+ # from additional_kwargs as Gemini strictly requires them to be passed back in subsequent tool calls.
540
  if hasattr(response, "additional_kwargs"):
 
541
  # Remove function_call duplicate if it exists in additional_kwargs (redundant with tool_calls)
542
  response.additional_kwargs.pop("function_call", None)
543
 
src/lilith_agent/observability.py CHANGED
@@ -97,13 +97,10 @@ def setup_logging(log_dir: str | Path = ".lilith") -> Path:
97
  # Keys stripped from every trace record — high-volume, low-signal noise
98
  # from provider responses (Gemini reasoning traces, safety metadata, etc).
99
  _NOISE_KEYS = frozenset({
100
- "__gemini_function_call_thought_signatures__",
101
  "reasoning",
102
  "signature",
103
  "safety_ratings",
104
  "safety_settings",
105
- "thought_signature",
106
- "thought_signatures",
107
  })
108
 
109
 
 
97
  # Keys stripped from every trace record — high-volume, low-signal noise
98
  # from provider responses (Gemini reasoning traces, safety metadata, etc).
99
  _NOISE_KEYS = frozenset({
 
100
  "reasoning",
101
  "signature",
102
  "safety_ratings",
103
  "safety_settings",
 
 
104
  })
105
 
106