Skip to content

Python: Filter caller options in hosting-responses README example - #9360

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
bschaeublin:docs/hosting-responses-option-allowlist
Oct 14, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
bschaeublin:docs/hosting-responses-option-allowlist

Conversation

@bschaeublin

@bschaeublin Benjamin Schäublin (bschaeublin) commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

responses_to_run() copies every caller-supplied Responses body field into options, and its docstring leaves it to app-owned route code to decide which options to pass to agent.run(...). The shipped local_responses and local_responses_harness samples do this with an ALLOWED_REQUEST_OPTIONS allowlist, but the agent-framework-hosting-responses README example passed run["options"] straight through.

An app built from that example lets callers set tools, instructions, or additional_function_arguments. The last one overrides app-bound tool kwargs, such as a user_id the app derives from authentication.

Description & Review Guide

  • What are the major changes? The README example now filters run["options"] through the same ALLOWED_REQUEST_OPTIONS = frozenset({"max_tokens", "reasoning"}) allowlist that samples/04-hosting/af-hosting/local_responses/app.py uses.
  • What is the impact of these changes? Documentation only. Developers copying the README get a deny-by-default example consistent with the samples. The allowlist uses Agent Framework option names, because responses_to_run() already remaps max_output_tokens to max_tokens.
  • What do you want reviewers to focus on? Whether the README should mirror the sample's allowlist exactly, or show a different minimal set.

Related Issue

N/A - trivial change: makes the README example consistent with the shipped local_responses sample, which already filters caller options with the same allowlist. The README was the only example passing run["options"] through unfiltered.

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 identify the inconsistency, prepare the README change, and draft this description. I checked the before and after behaviour locally against the published agent-framework-core 1.21.0 and agent-framework-hosting-responses 1.0.0a261008 packages.

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 README route passed every caller-supplied Responses body field from
responses_to_run() straight to agent.run(). Apps copying it let callers
set tools, instructions, or additional_function_arguments, which override
app-owned tool kwargs. Allowlist request options the same way the
local_responses samples already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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 documentation example now consistently applies the established sample allowlist without introducing functional issues.

0 open findings

What changed in this PR

Updates the hosting-responses README example to safely filter caller-controlled agent options.

Changes:

  • Adds an allowlist matching existing hosting samples.
  • Passes only permitted options to agent.run().
File Description
python/​packages/​hosting-responses/​README.md Demonstrates deny-by-default request option filtering.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Merged via the queue into microsoft:main with commit bdca454 Oct 14, 2026
58 of 62 checks passed
@bschaeublin
Benjamin Schäublin (bschaeublin) deleted the docs/hosting-responses-option-allowlist branch October 14, 2026 09:29

This branch was successfully deployed

1 active deployment
github-app-auth — e3315828 Deployed Oct 13, 2026 by bschaeublin via add_label #25238
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants