Repository navigation
Add truncation to ExecuteBashObservation and TextContent with warning checks - #124
Merged
Merged
Conversation
… checks - Move truncate.py from str_replace_editor to SDK utils for shared usage - Add truncation to ExecuteBashObservation.agent_observation with 30,000 char limit - Add warning check and truncation to TextContent.to_llm_dict with 50,000 char limit - Update str_replace_editor to use SDK truncate utility - Add comprehensive tests for all truncation functionality Fixes #123 Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
- Restore str_replace_editor specific truncate.py file - Import str_replace_editor specific constants from prompts.py - Remove duplicate imports in editor.py - Keep SDK truncate utility focused on general functionality - Maintain backward compatibility for str_replace_editor Co-authored-by: openhands <openhands@all-hands.dev>
- Modified maybe_truncate function to preserve head and tail content - Updated all tests to reflect new head-and-tail behavior - Fixed line length issues in tests - All 18 tests passing Co-authored-by: openhands <openhands@all-hands.dev>
- Removed DEFAULT_BASH_TRUNCATE_LIMIT from SDK utils - Updated execute_bash to use existing MAX_CMD_OUTPUT_SIZE constant - Updated imports and tests to use the correct constant - Maintains proper separation of concerns between SDK and tools Co-authored-by: openhands <openhands@all-hands.dev>
- Removed complex notice length handling logic - Kept simple head-and-tail approach with proper odd number handling - Updated tests to match simplified behavior - Function is now much cleaner and easier to understand Co-authored-by: openhands <openhands@all-hands.dev>
- Fix str_replace_editor to properly pass truncate_after parameter to maybe_truncate - Add test for str_replace_editor view operation truncation functionality - Ensure truncation works correctly with the editor's MAX_RESPONSE_LEN_CHAR limit Co-authored-by: openhands <openhands@all-hands.dev>
- Move MAX_RESPONSE_LEN_CHAR from utils/truncate.py to utils/prompts.py - Remove redundant utils/truncate.py file that only re-exported SDK functions - Update imports to use SDK's maybe_truncate directly - Consolidate str_replace_editor constants in prompts.py Co-authored-by: openhands <openhands@all-hands.dev>
xingyaoww
enabled auto-merge (squash)
September 6, 2025 02:47
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
StressTestor
pushed a commit
to StressTestor/software-agent-sdk
that referenced
this pull request
Jun 1, 2026
… checks (OpenHands#124) Co-authored-by: openhands <openhands@all-hands.dev>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements output truncation for
ExecuteBashObservationandTextContentwith warning checks as requested in issue #123.Changes Made
1. Moved truncation utility to SDK
openhands/tools/str_replace_editor/utils/truncate.pytoopenhands/sdk/utils/truncate.pyopenhands/sdk/utils/__init__.pyto export truncation utilities2. Added truncation to ExecuteBashObservation
ExecuteBashObservation.agent_observationproperty to usemaybe_truncate()with a 30,000 character limitDEFAULT_BASH_TRUNCATE_LIMITconstant for consistency3. Added warning check to TextContent
TextContent.to_llm_dict()method to:DEFAULT_TEXT_CONTENT_LIMITconstant4. Comprehensive testing
tests/sdk/utils/test_truncate.pywith 8 test cases covering all truncation scenariostests/sdk/llm/test_message.pyfor TextContent truncation behaviortests/tools/execute_bash/test_observation_truncation.pywith 5 test cases for ExecuteBashObservationConstants Added
DEFAULT_BASH_TRUNCATE_LIMIT = 30_000- Character limit for bash output truncationDEFAULT_TEXT_CONTENT_LIMIT = 50_000- Character limit for TextContent with warningTesting
All tests pass successfully:
Backward Compatibility
This change is fully backward compatible:
Fixes
Closes #123
@xingyaoww can click here to continue refining the PR