Skip to content

Add Bedrock InvokeModel and InvokeModelWithResponseStream and support multi-turn tool calling across providers - #175

Open
lmolkova wants to merge 4 commits into
open-telemetry:mainfrom
lmolkova:mock-server-bedrock-invoke
Open

Add Bedrock InvokeModel and InvokeModelWithResponseStream and support multi-turn tool calling across providers#175
lmolkova wants to merge 4 commits into
open-telemetry:mainfrom
lmolkova:mock-server-bedrock-invoke

Conversation

@lmolkova

@lmolkova lmolkova commented Sep 4, 2026

Copy link
Copy Markdown
Member

What does this change do?

  • Adds Bedrock InvokeModel and InvokeModelWithResponseStream mock endpoints with token headers and AWS EventStream responses.
  • Enhances OpenAI and Anthropic endpoints to support multi-turn tool calling and unique sequential tool call IDs across agent handoffs.
  • Expands mock server test coverage for Bedrock endpoints and multi-turn tool calling.

Why?

Some gaps identified when migrating pythong-genai repo to this runner - open-telemetry/opentelemetry-python-genai#623

@lmolkova
lmolkova requested a review from a team as a code owner September 4, 2026 16:40
Copilot AI balanced review requested due to automatic review settings September 4, 2026 16:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Required Bedrock content-type headers and robust deterministic stream validation are missing.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds mock Bedrock text-generation support for synchronous and streaming invocation.

Changes:

  • Adds Titan text responses with token headers.
  • Adds AWS EventStream streaming responses.
  • Adds endpoint tests.
File summaries
File Description
bedrock.py Implements synchronous and streaming invocation responses.
test_mock_server.py Adds coverage for invocation endpoints.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/gen-ai/mock-server/src/genai_mock_server/bedrock.py
Comment thread tools/gen-ai/mock-server/src/genai_mock_server/bedrock.py
Comment thread tools/gen-ai/mock-server/tests/test_mock_server.py
Comment thread tools/gen-ai/mock-server/tests/test_mock_server.py Outdated
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 4, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-05 01:33 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@lmolkova lmolkova changed the title Add Bedrock InvokeModel and InvokeModelWithResponseStream mock endpoints Add Bedrock InvokeModel and InvokeModelWithResponseStream and support multi-turn tool calling across providers Sep 4, 2026
@lmolkova
lmolkova requested a balanced review from Copilot September 4, 2026 19:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Repeated tool use is incorrectly suppressed, and the Titan stream payload does not match the expected response schema.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread tools/gen-ai/mock-server/src/genai_mock_server/anthropic.py Outdated
Comment thread tools/gen-ai/mock-server/src/genai_mock_server/bedrock.py
Comment thread tools/gen-ai/mock-server/src/genai_mock_server/openai.py
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 4, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

…chunks

A tool name was treated as exhausted for the whole message history, so a new
user turn offering the same tool got text instead of a call. Both providers now
look only at the messages since the last user message, and apply the same
precedence: no result in this turn calls the tool, a result with calls to
attribute it to calls only an uncalled tool, and a result with no matching call
ends the exchange.

InvokeModelWithResponseStream also carried the non-streaming tokenCount fields.
Titan streams index plus a cumulative totalOutputTextTokenCount that is null
until the final chunk.

Assisted-by: Claude Opus 5
@lmolkova
lmolkova force-pushed the mock-server-bedrock-invoke branch from be3183a to f41bf98 Compare September 4, 2026 23:38
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