Commit ef510c4
feat: Add LangGraph hosted-agent samples on top of langchain_azure_ai.agents.hosting (#324)
* Add LangGraph Responses sample: chat with local tools
Adds samples/python/hosted-agents/langgraph/responses/01-langgraph-chat:
- LangGraph agent built with langchain.agents.create_agent
- Two local tools: get_current_time, calculator
- Hosted with LangGraphResponsesHostServer (langchain_azure_ai.agents.hosting)
- Multi-turn via platform-managed previous_response_id
Also adds the LangGraph parent README (samples/python/hosted-agents/langgraph/README.md) modeled on the agent-framework parent, and the test-payload for cloud E2E pipeline.
* Add LangGraph Responses sample: Foundry Toolbox
Adds samples/python/hosted-agents/langgraph/responses/02-foundry-toolbox:
- LangGraph agent loading tools from a Foundry Toolbox via AzureAIProjectToolbox
- Manifest provisions a toolbox with web_search + code_interpreter
- Hosted with LangGraphResponsesHostServer (langchain_azure_ai.agents.hosting)
Includes test-payload for the cloud E2E pipeline.
* Add LangGraph Invocations sample: chat with local tools
Adds samples/python/hosted-agents/langgraph/invocations/01-langgraph-chat:
- LangGraph agent with get_current_time + calculator tools
- Hosted with LangGraphInvocationsHostServer (langchain_azure_ai.agents.hosting)
- Multi-turn via agent_session_id wired to a LangGraph MemorySaver checkpointer
- Supports streaming SSE token deltas with {\"stream\": true}
Includes test-payload for the cloud E2E pipeline.
* fix(cloud-e2e): pass --output json to azd ai agent show for jq parsing
* use AzureChatOpenAI
* revert to use ChatOpenAI but keeps token provider
* sync with new class name
* Add LangGraph Responses sample: remote MCP tools
* Add LangGraph Responses sample: multi-agent workflow
* Add LangGraph Responses sample: files and code interpreter
* Add LangGraph Responses sample: human-in-the-loop
* Add LangGraph Responses sample: observability
* docs: list new LangGraph samples in parent READMEs
* tweak to fix e2e
* use AzureAIOpenAIApiChatModel
* revert to use ChatOpenAI
* docs(langgraph): add Foundry Toolkit VS Code Extension subsections to sample READMEs
Adds two subsections to all 8 LangGraph sample READMEs, mirroring the agent-framework sample convention:
- Test in Agent Inspector (under 'Interacting with the agent') with a sample-specific message
- Deploying with the Foundry Toolkit VS Code Extension (under 'Deploying the Agent to Foundry') with the 5-step wizard
* refactor(langgraph): rename 02-foundry-toolbox -> 02-langgraph-toolbox; align with BYO
Mirror samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox:
- Rename folder via git mv (history preserved); agent name is now toolbox-langgraph.
- Swap scenario from web_search + code_interpreter to web_search + GitHub
Copilot MCP via a connection-backed Toolbox tool (custom-keys auth).
- agent.manifest.yaml: add github_pat parameter (kind: string, secret: true)
and a github-mcp-conn RemoteTool connection; toolbox now lists web_search +
the MCP tool wired via project_connection_id.
- main.py: add citation-grounded SYSTEM_PROMPT, OAuth consent helpers, and a
tool schema sanitizer; install handle_tool_error on every loaded tool so
consent (-32006) errors surface a friendly URL instead of crashing.
- README.md: rewrite scenario, add Prerequisites (azd env set GITHUB_PAT),
sample queries for web_search and GitHub MCP, and a Troubleshooting
section adapted from BYO.
- Update parent sample tables in langgraph/README.md and hosted-agents/README.md.
* build(langgraph): use public langchain-azure-ai 1.2.4 instead of local wheels
The hosting extra (ResponsesHostServer / InvocationsHostServer) shipped in
langchain-azure-ai 1.2.4 on PyPI, so the samples no longer need to install
the local 1.2.3+local wheel from a wheels/ directory.
- Drop --find-links ./wheels and pin langchain-azure-ai[hosting]>=1.2.4
(and [hosting,opentelemetry]>=1.2.4 for 08-observability).
- Remove the vendored langchain_azure_ai-1.2.3+local wheel from all 8
langgraph samples.
* fix(langgraph): align 02-langgraph-toolbox manifest with BYO for E2E pipeline
The cloud E2E pipeline (azd) failed to resolve the github_pat secret with
the parameters.properties[] form, erroring: 'unable to prompt for secret
parameter in no-prompt mode'. The BYO langgraph-toolbox manifest, which
the pipeline accepts, uses the flat-map parameters.<name> form instead.
- Switch parameters to the flat-map form (drops kind: string).
- Drop the yaml-language-server schema reference: the IDE schema requires
parameters.properties[] which the cloud pipeline does not accept.
- Align the github-mcp-conn connection with BYO: category: remoteTool
(lowercase) and drop the redundant authType field.
- Add server_url to the MCP toolbox tool to match BYO.
* fix(langgraph): lazy-load toolbox in 02-langgraph-toolbox to fix session_not_ready
Foundry's session manager waits for /readiness to return 200 before
routing the first /responses request. The eager asyncio.run(_load_toolbox_tools())
in main() blocked the HTTP server from coming up; if the toolbox call exceeded
the readiness timeout the session never became ready and clients got HTTP 424
session_not_ready.
Subclass ResponsesHostServer as _LazyToolboxHostServer: start with a placeholder
empty-tools graph so the server can serve /readiness immediately, then build
the real toolbox-bound graph inside a double-checked lock on the first request.
Mirrors the lazy pattern used by the BYO langgraph-toolbox sample.
Update README to mention tools are loaded lazily on the first request.
* test(hosted-agents): split 06-files payload, drop dead 02-foundry-toolbox payload
06-files: turn 2 timed out on the cloud E2E pipeline (HTTP 408) because a
single turn chained get_cwd -> list_files -> read_file -> code_interpreter
and exceeded Foundry's per-request timeout. Split into three independent
turns: list tools, read file & report Q1 revenue, then compute the diff with
the code interpreter standalone.
02-foundry-toolbox: delete test-payload.txt — the cloud E2E workflow detects
any hosted-agents sample whose dir name contains 'toolbox' as is_toolbox=true
and overrides PAYLOAD_FILE with TOOLBOX_QUERY, so the per-sample payload was
never read.
* ci(hosted-agents): route 02-langgraph-toolbox to westus2 toolbox project
The ncus toolbox project still reproduces the Foundry MCP dot-prefix
tool-name bug for Foundry-hosted toolboxes (web-search, ms-learn,
github-mcp); westus2 has the fix. The BYO langgraph-toolbox sample
passes in CI for exactly this reason — it is already in the use_westus2
list while 02-langgraph-toolbox was not, causing its github-mcp tool to
fail at runtime with 'Authorization header is badly formatted' against
https://api.githubcopilot.com/mcp.
Add samples/python/hosted-agents/langgraph/responses/02-langgraph-toolbox
to the use_westus2 case so it deploys against the same fixed project as
its BYO parity.
* ci(hosted-agents): use GH_PAT secret for github_pat
GitHub forbids user-defined secret names that start with GITHUB_, so
rename the lookup from secrets.GITHUB_PAT to secrets.GH_PAT. The
secrets.GITHUB_TOKEN fallback is unchanged (that one is auto-issued
by Actions and is fine to read).
* fix(ci): support non-src scaffold paths in hosted agents e2e
* fix: normalize nested azd project dir in cloud hosted-agents e2e
* ci(hosted-agents): pin azure.ai.agents extension to 0.1.34-preview
Newer extension builds omit the Foundry-Features: HostedAgents=V1Preview
header on 'azd ai agent invoke -p invocations', which the platform now
rejects with HTTP 403 preview_feature_required. 0.1.34-preview still
sends the header.
* revert(langgraph): drop 02-langgraph-toolbox sample to unblock PR
The toolbox sample's E2E job is blocked on platform-side fixes (MCP
tool-name dot-prefix bug on ncus, github-mcp PAT routing, and the
preview_feature_required header gate on the invocations protocol).
Remove the sample directory, the two README rows that listed it, and
the westus2 routing entry so the PR can merge with the remaining
LangGraph samples.
The sample, including all iteration history, is preserved on the
kuojianlu/langgraph-toolbox-backup branch and will be reintroduced
in a separate PR once the platform side stabilizes.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>1 parent 3488110 commit ef510c4
59 files changed
Lines changed: 2525 additions & 5 deletions
File tree
- samples/python/hosted-agents
- langgraph
- invocations/01-langgraph-chat
- responses
- 01-langgraph-chat
- 04-mcp
- 05-workflows
- 06-files
- resources
- 07-human-in-the-loop
- 08-observability
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
139 | 158 | | |
140 | 159 | | |
141 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments