Files
agent-framework/python/samples/getting_started/agents
T
Eduard van Valkenburg 35097d8c75 Python: Add long-running agents and background responses support (#3808)
* Python: Add long-running agents and background responses support

- Add ContinuationToken TypedDict to core types
- Add continuation_token field to ChatResponse, ChatResponseUpdate,
  AgentResponse, and AgentResponseUpdate
- Add background and continuation_token options to OpenAIResponsesOptions
- Implement polling via responses.retrieve() and streaming resumption
  in RawOpenAIResponsesClient
- Propagate continuation tokens through agent run() and
  map_chat_to_agent_update
- Fix streaming telemetry 'Failed to detach context' error in both
  ChatTelemetryLayer and AgentTelemetryLayer by avoiding
  trace.use_span() context attachment for async-managed spans
- Add 14 unit tests for continuation token types and background flows
- Add background_responses sample showing polling and stream resumption

Fixes #2478

* Python: Add A2A long-running task support via ContinuationToken

- Make ContinuationToken provider-agnostic (total=False, optional task_id/context_id fields)
- Add background param to A2AAgent.run() controlling token emission
- Add poll_task() for single-request task state retrieval
- Add resubscribe support via continuation_token param on run()
- Extract _updates_from_task() and _map_a2a_stream() for cleaner code
- Streamline run()/streaming by removing intermediate _stream_updates wrapper
- Update A2A sample to show background=False (default) with link to background_responses sample
- Remove stale BareAgent from __all__
- Add 12 new A2A continuation token tests

* fix logic for overriding continuation token when done

* refactored ContinuationToken setup
35097d8c75 ยท 2026-02-10 20:37:43 +00:00
History
..

Agent Examples

This folder contains examples demonstrating how to create and use agents with different chat clients from the Agent Framework. Each sub-folder focuses on a specific provider and client type, showing various capabilities like function tools, code interpreter, thread management, structured outputs, image processing, web search, Model Context Protocol (MCP) integration, and more.

Examples by Provider

Azure AI Foundry Examples

Folder Description
azure_ai_agent/ Create agents using Azure AI Agent Service (based on azure-ai-agents V1 package) including function tools, code interpreter, MCP integration, thread management, and more.
azure_ai/ Create agents using Azure AI Agent Service (based on azure-ai-projects V2 package) including function tools, code interpreter, MCP integration, thread management, and more.

Microsoft Copilot Studio Examples

Folder Description
copilotstudio/ Create agents using Microsoft Copilot Studio with streaming and non-streaming responses, authentication handling, and explicit configuration options

Azure OpenAI Examples

Folder Description
azure_openai/ Create agents using Azure OpenAI APIs with multiple client types (Assistants, Chat, and Responses clients) supporting function tools, code interpreter, thread management, and more

OpenAI Examples

Folder Description
openai/ Create agents using OpenAI APIs with comprehensive examples including Assistants, Chat, and Responses clients featuring function tools, code interpreter, file search, web search, MCP integration, image analysis/generation, structured outputs, reasoning, and thread management

Anthropic Examples

Folder Description
anthropic/ Create agents using Anthropic models through OpenAI Chat Client configuration, demonstrating tool calling capabilities

Custom Implementation Examples

Folder Description
custom/ Create custom agents and chat clients by extending the base framework classes, showing complete control over agent behavior and backend integration