Skip to content

Python: Fix declarative external-input docstring examples - #9753

Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-declarative-hitl-docstring
Draft

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-declarative-hitl-docstring

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

Motivation & Context

The AgentExternalInputRequest docstring in agent_framework_declarative/_workflows/_executors_agents.py is the in-code example for human-in-the-loop declarative workflows. It can't run as written:

  • from agent_framework import run_context raises ImportError. No such context manager exists.
  • workflow.run(ctx=ctx, stream=True): Workflow.run has no ctx parameter. Paused workflows resume with workflow.run(stream=True, responses={request_id: ...}).
  • It imports ExternalInputRequest and ExternalInputResponse, then uses AgentExternalInputRequest and AgentExternalInputResponse, which it never imports. These are different classes. The agent externalLoop emits AgentExternalInputRequest.

The two AgentExternalInputResponse examples have the same mismatch: they import ExternalInputResponse but construct AgentExternalInputResponse.

Description & Review Guide

  • What are the major changes? Docstrings only.
    • The request example now follows samples/03-workflows/declarative/customer_support/main.py. It streams the workflow and collects an AgentExternalInputResponse for each request_info event carrying an AgentExternalInputRequest. It then resumes with workflow.run(stream=True, responses=...) until no requests remain.
    • The response examples now import AgentExternalInputResponse.
    • The class summary now says it answers an AgentExternalInputRequest.
  • What is the impact of these changes? Documentation only.
  • What do you want reviewers to focus on? Nothing special.

I ran the new example against a small YAML workflow: one InvokeAzureAgent action with externalLoop.when: =Not(Local.Result.Done), a stub agent, and scripted answers. It paused twice, resumed with each answer, and finished after the agent reported Done: true. I found the problem by type-checking the code examples in the package docstrings.

Related Issue

N/A - trivial change: the docstring example is corrected to the documented request_info / responses= API, with no behavior change.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Claude Code helped find this by type-checking the docstring examples, run the corrected example against a stub workflow, make the edits, and draft this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

🤖 Generated with Claude Code

The AgentExternalInputRequest example imported a nonexistent run_context,
passed ctx= to Workflow.run and mixed up ExternalInput* and
AgentExternalInput* names. Show the request_info / responses= loop the
customer_support sample uses, and import AgentExternalInputResponse in the
response examples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 12:41
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 27, 2026

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.

🟢 Approval recommended

The focused documentation changes match the existing workflow API and exported types, with no unresolved findings.

No open issues 🎉

What changed in this PR

This documentation-only PR corrects the declarative workflow examples for handling agent requests for human input. No runtime behavior changes.

Changes:

  • Replaces the unsupported context-manager approach with streamed request_info handling and resumption through responses=.
  • Corrects imports and the response class summary to use the agent-specific request and response types.
File Description
python/​packages/​declarative/​agent_framework_declarative/​_workflows/​_executors_agents.py Corrects external-input docstring examples and response type references.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — fb27ea64 Deployed Oct 27, 2026 by 1aifanatic via team_check #7671
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants