Skip to content

Python: Extend max output limit to stderr - #9795

Merged
westey (westey-m) merged 3 commits into
microsoft:mainfrom
westey-m:shell-max-stderr
Oct 28, 2026
Merged

westey (westey-m) merged 3 commits into
microsoft:mainfrom
westey-m:shell-max-stderr

Conversation

@westey-m

Copy link
Copy Markdown
Collaborator

Motivation & Context

The container shell code limits the captured output on stdout, but was missing the same for stderr

Description & Review Guide

Extend max output limit to stderr.

Related Issue

Fixes #

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:

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.

Copilot AI balanced review requested due to automatic review settings October 28, 2026 12:56
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Oct 28, 2026
@github-actions github-actions Bot changed the title Extend max output limit to stderr Python: Extend max output limit to stderr Oct 28, 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.

🟡 Changes recommended

The change breaks existing max_output_bytes callers and leaves subprocess pipe transports open after reader cancellation, allowing descriptors and buffers to accumulate across repeated commands.

2 open issues
What changed in this PR

This PR extends bounded output capture to stderr in Agent Framework’s Python shell tools, covering local and Docker execution.

Changes:

  • Adds independent stdout and stderr limits with bounded head-and-tail capture.
  • Refactors persistent completion parsing and stateless capture cleanup.
  • Expands regression tests and documents output limits and host-memory considerations.
File Description
skills/​agent-framework-builder-python/​references/​harness-agent-builder.md Documents output limits and host resource responsibilities.
python/​packages/​tools/​tests/​test_shell_truncate_and_quote.py Tests bounded streaming capture and text decoding.
python/​packages/​tools/​tests/​test_shell_parse_rc.py Tests incremental completion-marker parsing.
python/​packages/​tools/​tests/​test_local_shell_tool.py Adds output-limit, recovery, and cleanup tests.
python/​packages/​tools/​tests/​test_docker_shell_tool.py Adds Docker capture and termination tests.
python/​packages/​tools/​README.md Explains independent limits and interruption behavior.
python/​packages/​tools/​agent_framework_tools/​shell/​_types.py Updates truncation documentation for separate limits.
python/​packages/​tools/​agent_framework_tools/​shell/​_truncate.py Adds bounded byte and text buffers.
python/​packages/​tools/​agent_framework_tools/​shell/​_tool.py Exposes and forwards separate local-shell limits.
python/​packages/​tools/​agent_framework_tools/​shell/​_session.py Uses bounded persistent capture and incremental marker parsing.
python/​packages/​tools/​agent_framework_tools/​shell/​_executor.py Integrates bounded stateless capture and cleanup.
python/​packages/​tools/​agent_framework_tools/​shell/​_docker.py Integrates separate limits and refactors container termination.
python/​packages/​tools/​agent_framework_tools/​shell/​_capture.py Introduces shared concurrent subprocess capture.

Review effort: Balanced

Comment thread python/packages/tools/agent_framework_tools/shell/_capture.py Outdated
Comment thread python/packages/tools/agent_framework_tools/shell/_tool.py

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (1 commit(s)): 95d20a6c8b8d
Model: gpt-5.6-sol

Overview

The change adds independent bounded capture for stdout and stderr, with strong coverage for unequal limits, truncation, cancellation, and persistent-session cleanup. Per-command buffers are bounded and released, and no shared-capacity security regression was established. Two compatibility and lifecycle gaps remain: the public constructor migration rejects the former keyword, and local stateless timeout cleanup can abandon a child that inherited the exited shell's pipes.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 2 files. Details are attached to the affected lines below.

Affected areas: python/packages/tools/agent_framework_tools/shell/_capture.py, python/packages/tools/agent_framework_tools/shell/_tool.py

Comment thread python/packages/tools/agent_framework_tools/shell/_tool.py
Comment thread python/packages/tools/agent_framework_tools/shell/_capture.py
@westey-m
westey (westey-m) added this pull request to the merge queue Oct 28, 2026
Merged via the queue into microsoft:main with commit 5817518 Oct 28, 2026
53 checks passed
@westey-m
westey (westey-m) deleted the shell-max-stderr branch October 28, 2026 19:40

This branch was successfully deployed

1 active deployment
github-app-auth — 6448b7f6 Deployed Oct 28, 2026 by westey-m via add_label #26454
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