Skip to content

Fix agent session continuity and tool metadata mapping#5

Merged
alexandephilia merged 1 commit into
mainfrom
fix-agent-continuity-and-tool-mapping-8798216175317638949
Mar 10, 2026
Merged

Fix agent session continuity and tool metadata mapping#5
alexandephilia merged 1 commit into
mainfrom
fix-agent-continuity-and-tool-mapping-8798216175317638949

Conversation

@alexandephilia

Copy link
Copy Markdown
Owner

This change addresses the issue where the AI agent would end sessions prematurely instead of maintaining a continuous tool-use loop.

Key improvements:

  1. Session Continuity: Implemented stable ConversationId generation based on the first message of a conversation. This ensures that subsequent turns are associated with the same session on the AWS CodeWhisperer backend. Added support for client-provided conversation_id in the Anthropic request.
  2. Structured Tool Metadata: Updated the mapping logic to correctly extract and include tool_use and tool_result blocks into CodeWhisperer's structured fields (toolUses and toolResults) for both the current message and the conversation history.
  3. Expanded Data Structures: Modified HistoryUserMessage and HistoryAssistantMessage to support full structured metadata storage.
  4. Response Continuity: The proxy now returns the conversation_id back to the client in the Anthropic response payload.

These changes allow the model to correctly reference its previous tool calls and their results, enabling stable agentic behavior.

Includes new tests for session continuity and tool mapping.


PR created automatically by Jules for task 8798216175317638949 started by @alexandephilia

This change addresses the issue where the AI agent would end sessions
prematurely instead of maintaining a continuous tool-use loop.

Key improvements:
1. Session Continuity: Implemented stable `ConversationId` generation
   based on the first message of a conversation. This ensures that
   subsequent turns are associated with the same session on the AWS
   CodeWhisperer backend. Added support for client-provided
   `conversation_id` in the Anthropic request.
2. Structured Tool Metadata: Updated the mapping logic to correctly
   extract and include `tool_use` and `tool_result` blocks into
   CodeWhisperer's structured fields (`toolUses` and `toolResults`)
   for both the current message and the conversation history.
3. Expanded Data Structures: Modified `HistoryUserMessage` and
   `HistoryAssistantMessage` to support full structured metadata
   storage.
4. Response Continuity: The proxy now returns the `conversation_id`
   back to the client in the Anthropic response payload.

These changes allow the model to correctly reference its previous tool
calls and their results, enabling stable agentic behavior.

Includes new tests for session continuity and tool mapping.

Co-authored-by: alexandephilia <43126944+alexandephilia@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 52fe1a142c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kirolink.go
// Heuristic: Use the first user message as a stable seed for the conversation.
// Note: We skip potential system prompts or earlier turns to keep it stable.
firstMsg := anthropicReq.Messages[0]
cwReq.ConversationState.ConversationId = generateDeterministicUUID(getMessageContent(firstMsg.Content))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid deriving session ID solely from first message

Generating conversationId from only getMessageContent(firstMsg.Content) causes unrelated chats to collide whenever they open with the same text (for example, many users start with "Hello") if the client does not send conversation_id. Because CodeWhisperer state is keyed by this ID, those collisions can merge tool/history context across distinct sessions, which is a functional and privacy regression compared with the previous random UUID behavior.

Useful? React with 👍 / 👎.

@alexandephilia alexandephilia merged commit 8802cb8 into main Mar 10, 2026
3 checks passed
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.

1 participant