fix(tools): Gracefully handle missing PS1 metadata instead of crashing#2742
fix(tools): Gracefully handle missing PS1 metadata instead of crashing#2742VascoSch92 wants to merge 2 commits intomainfrom
Conversation
When commands produce complex output (TUI rendering, ANSI escape sequences, large output), the PS1 metadata markers can be corrupted or scrolled off the terminal screen buffer. Previously this caused a hard assert crash. Now the session returns a valid observation with exit_code=-1 and a warning suffix, allowing the agent to continue. Fixes #2416 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
all-hands-bot
left a comment
There was a problem hiding this comment.
Pragmatic fix for a real crash. The fallback logic is sound and properly handles the edge case when PS1 metadata goes missing. Minor code duplication is acceptable given the simplicity trade-off.
|
@OpenHands fix the pre-commit check and follow the suggestion here #2742 (comment). Then push into this branch the changes. |
|
I'm on it! VascoSch92 can track my progress at all-hands.dev |
- Fix ruff format issues in terminal_session.py and test_terminal_ps1_metadata.py - Update test_ps1_corruption.py tests to verify graceful fallback behavior instead of expecting AssertionError (matches new graceful handling logic) Co-authored-by: openhands <openhands@all-hands.dev>
|
Fixed the pre-commit check and updated the tests in commit 8485fa5:
The review comment at discussion r3045624320 suggested documenting the exit_code=-1 sentinel but concluded it was "acceptable as-is" since the suffix message explains the situation to users. This comment was created by an AI assistant (OpenHands) on behalf of @VascoSch92. |
Summary of Work CompletedRequest Checklist
Changes Made (commit 8485fa5)1. Pre-commit formatting fixes:
2. Test updates in
Conciseness Check✅ All changes are directly related to fixing the CI failures - no extraneous changes were made. Notes
|
Coverage Report •
|
||||||||||||||||||||
|
[Automatic Post]: This PR seems to be currently waiting for review. @enyst, @xingyaoww, could you please take a look when you have a chance? |
Summary
assertin_handle_completed_commandwith a graceful fallback when no PS1 metadata markers are found in the terminal outputTerminalObservationwithexit_code=-1and a warning suffix instead of crashing the session###PS1JSON###...###PS1END###markers off the screen bufferFixes #2416
Test plan
test_issue_2416_missing_ps1_metadata_graceful_fallbackcargo testin a Rust project with TUI components inside OpenHandsAgent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:76ef39b-pythonRun
All tags pushed for this build
About Multi-Architecture Support
76ef39b-python) is a multi-arch manifest supporting both amd64 and arm6476ef39b-python-amd64) are also available if needed