Skip to content

chore: eliminate redundant work and inconsistency in TracingCallbacks#57

Merged
aakashb95 merged 1 commit into
chatwoot:mainfrom
sergiobayona:refactor/tracing-callbacks-simplify
Mar 17, 2026
Merged

chore: eliminate redundant work and inconsistency in TracingCallbacks#57
aakashb95 merged 1 commit into
chatwoot:mainfrom
sergiobayona:refactor/tracing-callbacks-simplify

Conversation

@sergiobayona
Copy link
Copy Markdown
Contributor

  • Cache llm_output_text result in handle_end_message and pass it to set_llm_response_attributes instead of both methods independently computing it, removing a duplicate serialization + format_tool_calls call per LLM response.

  • Simplify llm_output_text from three sequential format_tool_calls fallbacks into a single conditional with one fallback. Same behavior, clearer intent: "return content text if present, otherwise tool calls."

  • Fix inconsistent tool-call argument serialization: append_tool_calls used tc.arguments.to_json directly while format_tool_calls used serialize_output(tc.arguments). Both now use serialize_output for consistent handling of non-Hash/non-Array argument types.

- Cache llm_output_text result in handle_end_message and pass it to
  set_llm_response_attributes instead of both methods independently
  computing it, removing a duplicate serialization + format_tool_calls
  call per LLM response.

- Simplify llm_output_text from three sequential format_tool_calls
  fallbacks into a single conditional with one fallback. Same behavior,
  clearer intent: "return content text if present, otherwise tool calls."

- Fix inconsistent tool-call argument serialization: append_tool_calls
  used tc.arguments.to_json directly while format_tool_calls used
  serialize_output(tc.arguments). Both now use serialize_output for
  consistent handling of non-Hash/non-Array argument types.
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 13, 2026

Deploy Preview for ruby-ai-agents canceled.

Name Link
🔨 Latest commit 371fc07
🔍 Latest deploy log https://app.netlify.com/projects/ruby-ai-agents/deploys/69b36b792f18ec0008215851

@scmmishra scmmishra requested a review from aakashb95 March 13, 2026 04:48
@aakashb95 aakashb95 merged commit 993e6e7 into chatwoot:main Mar 17, 2026
7 checks passed
@aakashb95
Copy link
Copy Markdown
Contributor

Thanks for making the code clearer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants