Repository navigation
Python: fix empty local shell calls leaving orphaned history - #9803
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Service-side continuation and mixed-tool batches still discard synthetic shell-tool output, which can cause requests to fail with unresolved shell calls.
1 open issue
What changed in this PR
This PR addresses #9697 by pairing empty local shell calls with synthetic empty outputs, preventing orphaned calls in stateless conversation history without executing commands or requesting approval.
Changes:
- Generate empty results for valid empty calls targeting a configured local executor.
- Support replay of synthetic results while preserving
max_output_length. - Add 17 regression cases and document the no-op behavior; shell checkpoint persistence remains out of scope.
| File | Description |
|---|---|
python/packages/openai/tests/openai/test_openai_chat_client.py |
Adds parser, streaming, replay, and unaffected-case regression coverage. |
python/packages/openai/agent_framework_openai/_chat_client.py |
Creates synthetic empty shell results and supports their replay. |
docs/specs/004-python-function-calling-loop.md |
Defines empty local shell semantics and maps regression tests. |
Review effort: Balanced
|
M-Hietala, this change introduces a package-version coupling: |

Motivation & Context
Empty local shell calls (
commands=[]) currently leave a shell call without a matching output in conversation history. Stateless continuation can then fail with HTTP 400: “No tool output found for shell call.”This change treats an empty command list as a no-op and returns a matching empty output without executing a shell command.
A live Azure OpenAI check using a gpt-6.1-sol deployment confirmed that replaying the empty shell call without an output returns HTTP 400 (“No tool output found for shell call”). The same request with the matching shell_call_output containing output=[] completed successfully. No shell commands were executed.
Description & Review Guide
What are the major changes?
Pair empty shell calls for a configured local executor with
shell_call_outputcontainingoutput=[]. Support replay of the synthetic result, preservemax_output_length, and document the behavior in the function-loop specification. Add 17 regression cases covering both parsers, streaming finalization, replay, and unaffected cases.What is the impact of these changes?
Empty local shell calls no longer leave orphaned calls in stateless history. Hosted, unconfigured, and malformed calls retain their existing handling. The separate shell checkpoint-persistence issue (Python: [Bug]: LocalShellTool result text cannot be persisted by FileSessionStore #9696) is outside this change.
The core and OpenAI unit-test suites passed. A live Azure OpenAI check using a
gpt-6.1-soldeployment reproduced the missing-output error without the result and completed successfully with the paired empty output.What do you want reviewers to focus on?
The no-op interpretation, call/result pairing, and preservation of the local-versus-hosted shell boundary. No local execution or approval is entered for the empty command list.
Related Issue
Fixes #9697
AI Assistance
AI assistance details: Copilot assisted with implementation, tests, documentation, focused validation, the live-test diagnostic, and this PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after a language prefix) — a workflow keeps the label and title prefix in sync automatically.