fix(session): expand tool_call_id field limit & preserve tool function name in transcript - #95
Open
nipunanr wants to merge 3 commits into
Open
fix(session): expand tool_call_id field limit & preserve tool function name in transcript#95nipunanr wants to merge 3 commits into
nipunanr wants to merge 3 commits into
Conversation
Contributor
Confidence Score: 4/5The PR is not yet safe to merge because subsequent and resumed prompts still omit persisted tool function names.
Files Needing Attention: flow/flow/doctype/flow_session/flow_session.py Reviews (2): Last reviewed commit: "docs: update PR_DESCRIPTION.md with erro..." | Re-trigger Greptile |
Comment on lines
+106
to
+107
| tool_call_id_to_name: dict[str, str] = {} | ||
| return [_row_to_message(row, tool_call_id_to_name) for row in self.messages] |
Contributor
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR resolves two critical issues in Flow session message persistence and LiteLLM/Gemini API integration:
CharacterLengthExceededErrorwhen models (such as Google Gemini, Antigravity, or deep-thinking models) generate long thought tool call IDs (>140 characters).role: "tool"messages include their corresponding functionnameboth during execution loops and when reconstructing conversation transcripts from stored DB session messages.Problem & Root Cause
1.
tool_call_idTruncation (CharacterLengthExceededError)Flow Session Message(flow_session_message.json),tool_call_idwas defined asData(mapping toVARCHAR(140)). When advanced LLMs emitted long thought/tool call IDs (>140 chars), Frappe raised a validation error duringsession.save(), causing the Flow run to fail.2. LiteLLM / Gemini Tool Matching Error
role: "tool"response message to specify its functionname. Ifnameis omitted, LiteLLM attempts to matchtool_call_idagainstlast_message_with_tool_calls. In multi-turn sessions or resumed runs with ID sanitization/mismatches, LiteLLM failed to resolve the name and threw an API error.Proposed Changes
flow/flow/doctype/flow_session_message/flow_session_message.json&.pytool_call_idfieldtypefromDatatoSmall Text(textin MariaDB).flow_session_message.pytoDF.SmallText | None.flow/lib/agent.py_loop()and_resume_loop()to explicitly attach"name": call.nameto allrole: "tool"messages.flow/flow/doctype/flow_session/flow_session.py_row_to_message()andtranscript()to map preceding assistanttool_callsto their function names when reading stored transcript rows."name"torole: "tool"messages in transcript outputs.How Has This Been Tested?
bench migrateand verified thattabFlow Session Message.tool_call_idcolumn successfully converted totext.bench run-tests --app flow. All 98 core agent unit tests passed cleanly (OK).