Commit Graph

1268 Commits

Author SHA1 Message Date
Ben Thomas 00a08c55b0 Use released core with preview hosting wheel
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1674d491-af7d-4f9e-99aa-5a829db81591
2026-07-15 10:48:56 -07:00
Ben Thomas e139ad2a91 Fail fast without durability preview
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1674d491-af7d-4f9e-99aa-5a829db81591
2026-07-15 09:35:55 -07:00
Ben Thomas 1bfe26919c Document private preview wheel setup
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1674d491-af7d-4f9e-99aa-5a829db81591
2026-07-15 09:27:01 -07:00
Ben Thomas 094f3653b4 Fix durable workflow recovery boundaries
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1674d491-af7d-4f9e-99aa-5a829db81591
2026-07-15 09:04:53 -07:00
Ben Thomas 9208c65f44 Address durable workflow review feedback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1674d491-af7d-4f9e-99aa-5a829db81591
2026-07-14 20:28:49 -07:00
Ben Thomas 8936d718c9 Add durable workflow response recovery
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1674d491-af7d-4f9e-99aa-5a829db81591
2026-07-14 14:18:35 -07:00
Ben Thomas fa10c3f5bc fix: update agentserver wheel sources and fix 2 failing tests
- Switch agentserver wheel sources from GitHub raw URLs to find-links at
  local long-running-agents-private-preview checkout; remove [tool.uv.sources]
  URL entries from python/pyproject.toml
- Re-lock uv.lock for find-links path sources
- Guard tracker.close() in cancellation path to avoid ValueError when
  the SDK state machine is in not_started state
- Fix test assertions to access _ContextAwareCheckpointStorage._inner.storage_path
  instead of .storage_path (which is not exposed directly on the wrapper)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-14 14:18:34 -07:00
Tao Chen fca1bce5d0 Commit response state at checkpoint creation 2026-07-14 14:18:34 -07:00
Tao Chen de33b756cb Code cleanup 2026-07-14 14:18:33 -07:00
Tao Chen ce8aa4bd80 Remove non-streaming in invoking the inner agent 2026-07-14 14:18:33 -07:00
Tao Chen 072b8ddd0f Detect if checkpoint is supported via option and flag 2026-07-14 14:18:32 -07:00
Tao Chen d28d9c7d1d Add workflow context aware checkpoint storage and recovery path 2026-07-14 14:18:32 -07:00
Tao Chen d9e718e2f8 Add workflow sample 2026-07-14 14:18:31 -07:00
Tao Chen ec0ba56513 Fix samples 2026-07-13 14:56:01 -07:00
Ben Thomas d7b5f5c0ce Python: Replace manual kill steps with automated demo.py in 14_resilience
The previous README asked users to Ctrl+C the server at the right moment
while counting to 1000, which was unreliable and the model often refused
the prompt anyway.

demo.py orchestrates everything automatically:
1. Starts main.py as a subprocess
2. Sends a background request (returns in_progress immediately)
3. Kills the server after 2s (no timing pressure)
4. Restarts the server (recovery scanner fires)
5. Polls until the response completes and prints it

Uses a substantive prose prompt (explain how the internet works) that
reliably generates a long response without model refusals.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:54:49 -07:00
Ben Thomas d2053a4317 Python: Move steering and resilience to dedicated samples (13, 14)
- 01_basic: restore to minimal server-only sample; remove client.py,
  test_steering.py, and all steering/resilience content from README.
  Add brief 'Next steps' links to 13 and 14.

- 13_steering: new sample demonstrating steerable_conversations=True.
  main.py starts the server; client.py is an interactive two-terminal
  demo that sends two concurrent turns and shows the queued/steered flow.

- 14_resilience: new sample demonstrating resilient_background=True.
  main.py starts the server with crash recovery enabled. README walks
  through testing crash recovery locally (kill the server mid-response,
  restart, and poll the response to see it recover).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:54:49 -07:00
Ben Thomas e7e2692a71 Python: Add client.py steering demo to 01_basic sample
Add client.py — a two-terminal steering demonstration.  Run main.py in
one terminal and client.py in a second to see steering in action with a
real Foundry agent:

- Turn 1 streams the agent counting to 50
- 2 s later, turn 2 arrives on the same conversation with a different question
- Turn 2 is accepted with status=queued (not HTTP 409)
- Turn 1's handler is cancelled and emits response.completed with partial output
- Turn 2 runs and its answer is printed

client.py accepts an optional SERVER_URL argument so it can be pointed at
a deployed instance as well as localhost.

Also enable steerable_conversations=True in main.py and update README with
the two-terminal usage instructions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:54:49 -07:00
Ben Thomas d101df2fbe Python: Make resilient_background opt-in, remove auto-enable
resilient_background=True was previously auto-enabled when running in a
hosted Foundry environment. This is now opt-in: callers must pass it
explicitly via ResponsesServerOptions.

  server = ResponsesHostServer(
      agent,
      options=ResponsesServerOptions(resilient_background=True),
  )

Reasoning: auto-enabling crash recovery silently can cause unexpected
behaviour for agents with non-idempotent side effects. Requiring explicit
opt-in makes the behaviour transparent and intentional.

Updates:
- _responses.py: remove auto-enable logic and AgentConfig check
- test_responses.py: replace auto-enable tests with a single test
  asserting resilient_background is never auto-enabled
- 01_basic/main.py: rewrite comment to describe opt-in pattern
- 01_basic/README.md: rewrite durability section as opt-in

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:54:48 -07:00
Ben Thomas bc488965d8 Python: Update steering test to use real FoundryChatClient agent
Replaces the mock slow agent with a real FoundryChatClient + Agent using
FOUNDRY_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME env vars,
consistent with the 01_basic sample. Loads .env via python-dotenv.
Asks the agent to count to 100 (produces a long streaming response),
then steers with a joke request after 2s.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:54:47 -07:00
Ben Thomas bb37af0f01 Python: Fix _handle_response async generator + steering test
Fix async generator handler signature (b8 compatibility):
  _handle_response was async def returning AsyncIterable. The b8 SDK
  passes the raw handler result directly to _intercept_checkpoints which
  does 'async for raw in handler_iterator' — this fails on a coroutine
  with TypeError (caught as B8 pre-creation error), silently producing
  empty responses. Changed to async generator (using yield) so calling
  it returns an AsyncGenerator immediately iterable without awaiting.

Update 01_basic sample (durable_background -> resilient_background):
  main.py comments and README referenced the old durable_background field
  name (renamed to resilient_background in b8). Updated both to use the
  correct API and added steerable_conversations documentation.

Add steering integration test (test_steering.py):
  Self-contained end-to-end test using Hypercorn on a loopback port and
  concurrent asyncio tasks. Demonstrates the full steering flow:
  turn 1 streams, turn 2 arrives while turn 1 is in_progress and gets
  status=queued, turn 1 emits response.completed (cancellation terminal
  fix), turn 2 runs and completes. Requires clean ~/.agentserver state
  (no stale task files) on first run; uses unique UUID per test run.

Also add pre-existing sample exclusions to pyrightconfig.samples.json
for monty/tools samples not installed in the dev environment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:54:47 -07:00
Ben Thomas b2ee149c19 Python: Add steerable_conversations support to ResponsesHostServer
- Fix resilient_background rename: ResponsesServerOptions no longer
  accepts durable_background (renamed to resilient_background in b8).
  The old name caused a silent TypeError that disabled crash recovery
  in hosted environments.

- Add steerable_conversations parameter to ResponsesHostServer.__init__.
  When True, concurrent turns on the same conversation chain are queued
  rather than rejected with 409 conversation_locked. The flag is threaded
  into ResponsesServerOptions and composed with resilient_background in
  the auto-enable path for hosted environments.

- Fix streaming cancellation terminal: both _handle_inner_agent and
  _handle_inner_workflow now emit response.completed before returning
  when cancellation_signal fires. Per spec §10, the handler must emit
  a terminal event; the framework overrides completed → cancelled when
  context.client_cancelled=True (real client cancel), and leaves it as
  completed for steering pressure (client_cancelled=False). Previously
  returning without a terminal caused the framework to force failed,
  which broke the steered-turn chain.

- Add comment in _handle_inner_workflow explaining the relationship
  between previous_response_id and conversation_chain_id for steerable
  turns (they resolve to the same key, so the existing restore logic
  is already correct).

- Update tests: rename resilient_background tests, update cancellation
  test to assert response.completed is emitted, add three new tests
  for steerable_conversations threading and precedence rules.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:53:27 -07:00
Ben Thomas 084ce7bf5d Python: Bump azure-ai-agentserver-* to b7/b6/b8 pre-release wheels
- azure-ai-agentserver-core: 2.0.0b5 -> 2.0.0b7 (resilient task primitive, event streaming API)
- azure-ai-agentserver-invocations: 1.0.0b3 -> 1.0.0b6 (bug fixes, requires core >=b7)
- azure-ai-agentserver-responses: 1.0.0b7 -> 1.0.0b8 (resilient background responses, steerable conversations, developer checkpoints)

New versions are unreleased on PyPI; source them via direct URL to the
pinned commit in azure-sdk-for-python via [tool.uv.sources].

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-13 14:50:05 -07:00
pratik wayase 43568f1ef2 Fix: coalesce reasoning deltas into single block when content.id is None (#6804)
python/packages/ag-ui/tests/ag_ui/test_run_commoclear
:wq
2026-07-13 21:11:22 +00:00
VectorPeak 52005ff17d Python: accept AG-UI state data URI parameters (#6905)
* Python: Accept AG-UI state data URI parameters

* Python: Handle invalid AG-UI state base64

---------

Co-authored-by: VectorPeak <VectorPeak@users.noreply.github.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
2026-07-13 21:05:27 +00:00
pratik wayase a4e4a5a51c Python: Fix: Ollama parallel tool calls collide on same call_id (#6822)
* Fix: Ollama parallel tool calls collide on same call_id

* fix(ollama): use uuid4 for tool call IDs and support colons in tool names

---------

Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
2026-07-13 21:02:24 +00:00
Alireza Afzali c8fb491644 Python: docs: add env example files for durabletask samples (#5948)
* docs: add env example files for durabletask samples

* docs: clarify env example values and comments

* docs: set default Redis URL in streaming sample env example
2026-07-13 21:01:19 +00:00
westey c9b19e831f Gradudate mode and todo providers (#7053) 2026-07-13 13:47:53 +00:00
westey b3d523ee50 Python: [BREAKING] Fix harness before-strategy compaction under per-service-call persistence (#7055)
* Fix middleware ordering to ensure compaction runs

* Address PR comments

* Fix build issue
2026-07-13 09:51:00 +00:00
Tao Chen 8e74360d52 Python: Add Microsoft OpenTelemetry Distro sample (#5632)
* Add Microsoft OpenTelemetry Distro sample

* Verify and add README

* Add dependency header

* Add maf dependency in PEP 723 block
2026-07-13 01:51:15 +00:00
ByteWise 7f4cc296fd Python: preserve tool span context for parallel calls (#6512)
* Python: preserve tool span context for parallel calls

* Python: address parallel tool span review feedback

* Python: fix parallel tool span test checks

---------

Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
2026-07-13 00:07:53 +00:00
Benke Qu f3057ef20c Python: fix: clear service_session_id in _agent_wrapper when propagate_session=True (#5875)
* fix: clear service_session_id in _agent_wrapper when propagate_session=True

When propagate_session=True, the child agent inherits the parent's
service_session_id. After the parent's first LLM call, MAF auto-populates
this from the Responses API conversation_id. The child sends it as
previous_response_id which the server rejects because the parent's
tool_call is still pending (400 error).

This fix saves and clears service_session_id before calling the child
agent and restores it in a finally block, preserving session.state
sharing while isolating the server-side conversation pointer.

Fixes #5874

* refactor: use child session copy instead of in-place mutation

Address Copilot review comments:
- Create a child AgentSession with shared state dict but isolated
  service_session_id, avoiding race conditions under concurrent
  asyncio.gather tool invocations.
- Update tests to verify child gets a separate session object and
  that child-set service_session_id does not leak to parent.

* fix: update test_chat_agent_as_tool_propagate_session_true for child session isolation

The existing test asserted captured_session is parent_session, but since
we now create a separate child AgentSession (to avoid racing under concurrent
asyncio.gather), the child is a different object. Updated assertions to verify:
- child is NOT the parent object (isolation)
- child shares the same session_id and state dict (by reference)
- child's service_session_id is None (isolated)

* fix: add type narrowing asserts for captured_session

Add 'assert captured_session is not None' before attribute access to
satisfy mypy/pyright type checking on Optional values.

* Python: Fix test typing checks

---------

Co-authored-by: Benke Qu <bequ@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
Co-authored-by: Evan Mattson <evan.mattson@microsoft.com>
2026-07-12 23:37:53 +00:00
Eduard van Valkenburg 68136ee081 Python: Clean up dependency groups and compatibility (#7046)
* Python: Clean up dependency management

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2f7b1c89-f3ff-418d-ab4e-4f014fda308f

* Python: Harden Mistral SDK import fallback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2f7b1c89-f3ff-418d-ab4e-4f014fda308f
2026-07-10 22:40:42 +00:00
Evan Mattson 87af313119 Python: [BREAKING]: Emit TOOL_CALL events for workflow participant tool calls in AG-UI (#7039)
* Python: emit participant tool calls in AG-UI workflows

Decisions:
- Pass function call, function result, and approval request content from streaming agent updates regardless of role.
- Preserve the assistant-role gate for text and reuse the shared AG-UI content emitters without dual custom-event emission.

Files changed:
- packages/ag-ui/agent_framework_ag_ui/_workflow_run.py
- packages/ag-ui/tests/ag_ui/test_workflow_run.py

Verification:
- uv run poe test -P ag-ui
- uv run poe pyright -P ag-ui
- uv run poe test-typing -P ag-ui
- uv run poe syntax -P ag-ui -C

Notes:
- Existing workflow golden scenarios do not exercise participant tool calls, so no snapshot changed.
- No blockers.

* Python: guard participant tool call duplication

Decisions:
- Assert the workflow stream emits one TOOL_CALL_START when a streamed call is also present in final conversation history.
- Keep production flow unchanged because latest-assistant final-response conversion prevents duplication.

Files changed:
- packages/ag-ui/tests/ag_ui/test_workflow_run.py

Verification:
- uv run pytest packages/ag-ui/tests/ag_ui/test_workflow_run.py -k 'participant_tool_call or repeat_tool_call' -q
- uv run poe test -P ag-ui
- uv run poe pyright -P ag-ui
- uv run poe test-typing -P ag-ui
- uv run poe syntax -P ag-ui -C
- git diff --check

Notes:
- No blockers; no call-id guard was required.

* Python: scope workflow tool content bypass to resumable tool calls

- Exclude approval request content from the role bypass. Workflow approvals
  resume through request_info pending state, so an approval interrupt emitted
  from streamed content would have no pending request to resume against.
- Admit mcp_server_tool_call and mcp_server_tool_result so provider-hosted MCP
  tool calls from workflow participants emit standard tool call events.
- Add unit tests for MCP passthrough, approval exclusion, and mixed
  text-plus-tool content in non-assistant updates.
2026-07-10 16:58:07 +00:00
Evan Mattson 9ac548ad15 Python: keep attachments close (#7038)
* Python: keep attachments close

* Python: close attachment edge cases
2026-07-10 16:57:29 +00:00
HaoJun 32a547a1a7 Python: bind AG-UI tool arguments to call IDs (#6342)
Co-authored-by: White-Mouse <15983334+White-Mouse@users.noreply.github.com>
2026-07-10 06:54:53 +00:00
Evan Mattson 7464a59228 Python: Bump Python package versions for 1.11.0 release (#7035)
* Bump Python package versions for 1.11.0 release

Bump the CHANGELOG-selected packages for the 1.11.0 release: core and the root package move to 1.11.0 for the new stable APIs, Foundry and OpenAI receive patch bumps, changed prerelease packages receive the 260709 stamp or next RC counter, and Monty joins the bump set for corrected published dependency metadata. No beta cohort bump was applied. Raise core floors conservatively on every package publishing this cycle and correct dependency floors exposed by lower-bound validation.

Copilot-Session: ee33d338-c1fc-4182-9106-0345ccf26b8e

* Fix Gemini streaming type suppression

Move the targeted Pyright suppression to the SDK contents argument, where the google-genai invariant content-list alias produces the compatibility diagnostic, and remove the now-unnecessary member suppression.

Copilot-Session: ee33d338-c1fc-4182-9106-0345ccf26b8e

* Raise Monty core dependency floor

Align Monty with the conservative release policy by requiring agent-framework-core 1.11.0 or later for the package version published in this cycle.

Copilot-Session: ee33d338-c1fc-4182-9106-0345ccf26b8e
2026-07-10 12:15:26 +09:00
Ethan qu 01ec3b7bcf Fix AG-UI approval thread aliases (#6908)
Co-authored-by: godququ5-code <256881196+godququ5-code@users.noreply.github.com>
2026-07-10 00:51:49 +00:00
westey ce96fd4b72 Python: Integrate message injection into harness agent (#7027)
* Integrate message injection into harness agent and sample console

* Add agents.md update.

* Address PR comments
2026-07-10 00:33:31 +00:00
Evan Mattson 52237b8eff Python: consolidate dependency updates (#7033) 2026-07-10 00:25:30 +00:00
Giles Odigwe e6cc2c09af Python: Fix read_skill_resource instruction dropping .md extension (#7031)
The RESOURCE_INSTRUCTIONS example told the model to use

eferences/FAQ instead of 
eferences/FAQ.md, contradicting the
actual exact-match resource lookup (which lists and matches names
including the extension). This caused read_skill_resource to fail with
'Resource not found'. Align the example with the .NET original.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-10 00:06:09 +00:00
Chinedum Echeta 7440b1c376 feat: enhance tool choice handling for required mode in _prepare_options (#7024) 2026-07-09 22:57:16 +00:00
Eduard van Valkenburg d43e52df69 Python: support mem0ai 2.x (#7004)
* Python: support mem0ai 2.x

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* updated lock

* Address mem0 OSS application scope

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use filters for mem0 platform add

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-09 16:55:51 +00:00
westey fbaa346eec .NET: Python/.Net: Agent Harness blog post accompanying samples part 3 (#6741)
* Python/.Net: Agent Harness blog post accompanying samples part 3

* Delete inadvertently added files

* Address PR feedback.

* Rename files that are causing dotnet format failures

* Address PR comment

* Fix blog links
2026-07-09 13:52:53 +00:00
Sheldon 9f4526a41e fix: parse structured response value from final message (#6383)
Signed-off-by: liuzemei <35027683+liuzemei@users.noreply.github.com>
2026-07-09 11:58:39 +00:00
Sumesh Ramasamy 13fc425bf5 Python: docs: fix removed ChatAgent references in _clients.py docstrings (#6924)
* docs: fix removed ChatAgent references in _clients.py docstrings

* docs: make _clients.py tool-support examples copy/paste-safe

Import Agent in each tool-support protocol docstring example so
copy/pasting no longer raises NameError, and define the shell
executor (LocalShellTool) in the SupportsShellTool example.

Addresses Copilot review feedback on #6924.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: wrap SupportsShellTool example in async function

`async with LocalShellTool()` is a SyntaxError at module level, so the
copy/pasted snippet must live inside an async function to be valid.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Sumesh Bharathi Ramasamy <sumesh@iconicair.io>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 10:16:23 +00:00
Roger Barreto 5f9ac6b394 Python: bind policy-enforcement approvals to a single tool invocation (#6966)
* Bind policy-enforcement approvals to a single tool invocation

PolicyEnforcementFunctionMiddleware retained approved call_ids in a set
that was never cleared, so a reused call_id could re-authorize a later
or different tool call without a fresh approval. It also accepted an
approved response as long as the invocation metadata carried a pending
call_id, without checking the response id or embedded function_call.

Bind each approval to the exact invocation shown for review: call_id,
function name, arguments, the security label (integrity/confidentiality),
and the session. Validate that the approval response itself names the
pending request (its id and embedded function_call), and consume the
approval on first use. A reused call_id, a different function, changed
arguments, an escalated label, a different session, or a mismatched
approved response now all require a fresh approval. Adds regression tests
covering each of those cases plus legitimate re-approval.

* Require approval response identifiers to be present and match

Make the policy-enforcement approval-response check reject a response
that omits its id or embedded function_call.call_id: both must now be
present and equal to the pending call_id, closing a None-identifier
bypass. Adds a regression test.

* Disclose all policy violations in a single approval request

PolicyEnforcementFunctionMiddleware computed the approval decision once
and reused it across the integrity and confidentiality checks, so a call
that violated both policies produced an approval request describing only
the untrusted-context violation and then silently waved the undisclosed
confidentiality violation on replay.

Detect every applicable violation up front and surface them together in a
single approval request, so a granted approval waves only what it
disclosed. The binding (call_id, function, arguments, security label,
session) and consume-once behavior are unchanged. Adds a regression test
covering a combined untrusted-context and confidentiality violation.

* Bind policy approval to the disclosed violation set and fingerprint

A pending policy approval was bound to the call body, security label, and
session but not to the violations it disclosed. Because the violation set
depends on the tool's policy metadata (max_allowed_confidentiality,
accepts_untrusted), a replay could compute a different or larger set after
that metadata changed and execute it under the old approval even though the
user never reviewed that risk.

Record the canonical disclosed violation fingerprint (type plus reason) in
the pending record and require the replay to trip the same set, otherwise
re-request approval disclosing the new set. Also require the approval
response's approved flag to be a strict boolean True so a truthy non-boolean
value is not treated as approval. Adds regression tests for a new violation
appearing on replay, a same-type violation whose disclosed risk worsened,
and a non-boolean approved flag.
2026-07-09 10:01:53 +00:00
Eduard van Valkenburg 1aca7601b8 Python: Add hosting protocol helper surface (#6891)
* Add Python hosting protocol helper surface

Introduce AgentFrameworkState and SessionStore for app-owned hosting routes, add Responses run conversion/rendering helpers, and update the local Responses sample to use native FastAPI routing with streaming support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix CI failures, session continuity, and streaming model reporting

- Fix constrained TargetT TypeVar in AgentFrameworkState: split __init__
  into per-shape overloads (instance/sync factory/async factory/awaitable)
  since a bound TypeVar combined with one big Callable/Awaitable union
  parameter was unsolvable across pyright/pyrefly/ty/zuban.
- Fix _FakeAgent test fixtures to structurally satisfy SupportsAgentRun
  (matching attribute types and overloaded run()), which the above surfaced.
- Add SessionStore.put() to alias an additional session id to an
  already-resolved session, and use it in the local_responses sample to fix
  a real session-continuity bug: previous_response_id rotates every turn,
  so without aliasing the newly minted response id, turn 3+ of a
  conversation silently lost all prior history. Verified against a live
  Foundry model across a 3-turn conversation.
- Fix responses_stream_events_from_run to report the real model instead of
  the "agent" fallback: AgentResponse.from_updates never carries a raw
  representation forward, so capture model from the individual streamed
  updates' raw representations instead. Verified live.
- Add response_model=None to the sample's FastAPI route (it could not boot
  at all: FastAPI tried to build a Pydantic response model from the
  JSONResponse | StreamingResponse return annotation).
- Map responses_to_run's ValueError to HTTP 400 instead of a 500.
- Add HTTP round-trip integration tests (packages/hosting-responses) that
  exercise the same FastAPI + AgentFrameworkState + Responses helper wiring
  as the sample via httpx.ASGITransport, including a regression test for
  the session-continuity fix.
- Add Workflow-target test coverage, SessionStore.put/reset_session tests,
  and TypeError-path coverage to packages/hosting/tests/hosting/test_state.py.
- Extend call_server.py / call_server_af.py to a third conversation turn so
  they actually exercise the continuity chain (previous scripts stopped at
  turn 2, which would never have revealed the bug above).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Simplify session-continuity aliasing: fold put() into get()

Per feedback: the growth of SessionStore was not the problem -- it's
intentional, since OpenAI's previous_response_id is designed to let a
caller continue (fork) from any earlier response, not just the latest
one, so every response id has to stay independently resolvable. That
part stays as-is.

What was too complex was the call site: routes had to manually fetch a
session and then conditionally alias it with a separate put() call.
Folded that into a single get(session_id, alias=...) call instead:

- SessionStore.get() gains an optional `alias` keyword that registers an
  additional id for the same session in the same call (no-op if alias is
  None or equal to session_id). Removed the separate put() method.
- AgentFrameworkState.get_session() passes `alias` through.
- local_responses sample and the HTTP round-trip integration tests now
  do `await state.get_session(lookup_id, alias=response_id)` instead of
  pulling the store out and orchestrating get()/put() by hand.
- Documented that this in-memory SessionStore intentionally never evicts
  (by design, to support forking), and that a storage-backed replacement
  (Redis, a database, ...) is responsible for its own TTL/eviction
  policy.

Verified against a live Foundry model across a 3-turn previous_response_id
chain after the simplification.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Refine hosting state helpers

Split the shared state surface into AgentState and WorkflowState, keep SessionStore and CheckpointStore as plain storage, and make state helpers responsible for get-or-create behavior. Update the Responses sample and HTTP round-trip tests to store the post-run session explicitly under the minted response id, and support WorkflowBuilder/orchestration-style builders via structural build() support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix hosting state test protocol fakes

Widen fake agents' get_session service_session_id parameter to match the SupportsAgentRun protocol under the Python 3.11 test typing checkers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Simplify Responses stream helper naming

Rename responses_stream_events_from_run to responses_stream_from_run across exports, tests, docs, and the local Responses sample to align with the generic <protocol>_stream_from_run helper convention.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add state-level storage setters

Add AgentState.set_session and WorkflowState.set_checkpoint_storage so app code can pair get-or-create helpers with explicit post-run storage without reaching into the underlying stores. Update Responses docs, tests, and sample to use state.set_session.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Simplify WorkflowState checkpoint handling

Remove CheckpointStore from WorkflowState so workflow checkpointing uses the existing CheckpointStorage abstraction directly. Keep WorkflowState focused on resolving workflow targets, including builders, and update hosting docs/tests accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Rename Responses streaming run helper

Rename responses_stream_from_run to responses_from_streaming_run across the hosting-responses exports, tests, docs, and local Responses sample.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Align Python hosting spec with protocol helpers

Rewrite SPEC-002 to match the accepted helper-first hosting ADR and the implementation PR: AgentState, WorkflowState, SessionStore, Responses helpers, app-owned security/state responsibilities, and the minimal FastAPI Responses shape.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove old Python hosting channel implementation

Remove the unreleased AgentFrameworkHost/channel implementation, the old hosting-telegram package, and old host/channel samples. Keep agent-framework-hosting focused on AgentState, WorkflowState, and SessionStore, and keep hosting-responses focused on helper-first Responses conversion. Update SPEC-002 to match the accepted helper-first ADR and the implementation surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Restore helper-first workflow sample

Rebuild the local Responses workflow sample on the protocol-helper surface, add production-readiness cautions to the local hosting samples, and align file-backed workflow checkpoint/cursor storage under one sample storage root.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address hosting helper review feedback

Handle streaming failures as terminal Responses SSE events, guard concurrent target/session initialization, and scope workflow sample checkpoint storage per continuation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Clarify Responses sample continuation behavior

Document unknown conversation_id behavior in the agent sample and make the workflow sample explicitly reject conversation_id while continuing to use responses_session_id for previous_response_id.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Clarify Responses sample option policy

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-09 07:51:47 +00:00
Eduard van Valkenburg 9a5312b278 Python: Add message injection middleware (#6998)
* Python: Add message injection middleware

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Python: Ignore informational tool calls for message injection

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Python: Preserve per-service history with message injection

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-09 07:47:39 +00:00
Ethan qu 978cfcd9e4 Python: Fix Foundry reasoning MCP compaction (#6907)
* Fix Foundry reasoning MCP compaction

* Address reasoning MCP review feedback

---------

Co-authored-by: godququ5-code <256881196+godququ5-code@users.noreply.github.com>
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
2026-07-09 07:10:39 +00:00
VectorPeak 7a73455e56 Python: normalize single Anthropic tools (#6903)
* Python: Normalize Anthropic single tools

* Potential fix for pull request finding

Thanks

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Python: Address Anthropic review feedback

---------

Co-authored-by: VectorPeak <VectorPeak@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-09 07:05:24 +00:00