Skip to content

Adapter redesign option c - #11896

Closed
rama0120 wants to merge 12 commits into
azure-sdk:mainfrom
rama0120:adapter-redesign-option-c
Closed

rama0120 wants to merge 12 commits into
azure-sdk:mainfrom
rama0120:adapter-redesign-option-c

Conversation

@rama0120

Copy link
Copy Markdown

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

rama0120 and others added 4 commits February 19, 2026 01:02
- New AgentServer class: POST /invoke, GET /liveness, GET /readiness
- invoke_loader: importlib-based function loading with sync/async detection
- Dict returns → JSONResponse, generators → SSE StreamingResponse
- Sync invoke functions auto-wrapped via asyncio.to_thread()
- First-event prefetch for early error detection in streams
- Removed: FoundryCBAgent, AgentRunContext, OpenAI type re-exports
- Preserved: logger.py, constants.py, models/projects/

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- New invoke.py: create_invoke_handler(graph) → invoke(dict) -> dict|generator
- from_langgraph(graph) now returns AgentServer (not LangGraphAdapter)
- Removed: LangGraphAdapter, 7 event generators, 4 converters, utils
- Simplified deps: dropped langchain-openai, opentelemetry-exporter
- Net: ~150 lines replace ~1,600 lines

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

- New invoke.py: create_invoke_handler(agent) → invoke(dict) -> dict|generator
- from_agent_framework(agent) now returns AgentServer (not AgentFrameworkCBAgent)
- Removed: AgentFrameworkCBAgent, 595-line streaming state machine, converters
- Simplified deps: dropped opentelemetry-exporter-otlp-proto-grpc
- Interrupt/resume mapping preserved via FunctionResultContent
- Net: ~200 lines replace ~1,100 lines

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

Copy link
Copy Markdown

Thank you for your contribution @rama0120! We will review the pull request and get back to you soon.

rama0120 and others added 8 commits February 19, 2026 17:53
- minimal-invoke/: raw invoke() function, no framework deps, streaming + non-streaming
- langgraph-agent/: from_langgraph(graph).run() pattern with a simple chatbot
- maf-agent/: from_agent_framework(agent).run() pattern with echo agent
- Each sample includes main.py, agent definition, and README with curl examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gents/ repo)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AgentServer._dispatch() now accepts caller_wants_stream flag.
When invoke() returns a dict and the caller sent stream:true,
the dict is auto-wrapped as a single invocation.completed SSE event.

This means the customer implements ONE return type — they never
branch on request.get('stream'). Real token-level streaming is
opt-in by returning an async generator instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1. Remove stream branching from LangGraph and MAF wrappers — both now
   return a dict only, matching decision azure-sdk#8 (one return type, not two).
   Server auto-wraps as SSE when caller requests streaming.

2. Fix resume context loss in MAF wrapper — _build_resume_input now
   appends the FunctionResultContent to the original message list
   instead of replacing it.

3. Replace deprecated asyncio.get_event_loop() with get_running_loop()
   in _wrap_sync_generator (deprecated since Python 3.10).

4. Add try/finally to _wrap_sync_generator to ensure gen.close() is
   called even when exceptions occur, preventing resource leaks.

5. Replace print() with structured logger in invoke_loader.py.

6. Remove dead code: streaming-only helpers (_stream, _extract_text,
   _extract_interrupt) deleted from both wrappers. Unused AsyncGenerator
   imports removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1. Add interrupt detection to LangGraph wrapper: checks for tool_calls
   on the last message and returns status="requires_input" with
   the pending tool call details. This matches MAF wrapper parity.

2. Update empty message handling: both wrappers now return message=None
   instead of empty string when no text content is produced.

3. Fix MAF multi-tool call overwrite: (previous commit) ensures
   first interrupt is preserved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Rewrite core/langgraph/agentframework READMEs with AgentServer examples
- Remove stale core deps (openai, azure-ai-projects, azure-ai-agents)
- Loosen MAF pyproject.toml version pins (== → >=)
- Remove unused os import from MAF wrapper
- Update conftest.py and test_custom.py: /responses → /invoke
- Rewrite LangGraph unit tests for _to_langchain_messages
- Rewrite MAF unit tests for _to_maf_input/_response_from_result
- Rewrite simple_mock_agent sample with AgentServer/invoke API
- Fix all sample READMEs: port 8088 → 8080, /responses → /invoke

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

Address Bedrock SDK review findings (F-1, F-3, F-4, F-7):

- Add lifespan parameter to AgentServer for startup/shutdown hooks
- Add _serialize_complex() fallback chain: json → model_dump → asdict → str
- Auto-detect Docker for host binding (0.0.0.0 vs 127.0.0.1)
- Replace asyncio.to_thread() with copy_context() + run_in_executor()

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exposes X-Platform-* and tracing headers (traceparent, X-Request-Id) via
a contextvar-based opt-in mechanism. Most agents never use this — the
invoke(dict) signature is unchanged. Agents needing OBO tokens or
platform context can call get_platform_context().

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

Copy link
Copy Markdown

Hi @rama0120. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

Hi @rama0120. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing /reopen if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the no-recent-activity label; otherwise, this is likely to be closed again with the next cleanup pass.

@github-actions github-actions Bot closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant