If the condenser is not configured, and the contex...
# proj-sdk
q
If the condenser is not configured, and the context window length is reached how does the agent-sdk handle the error path? It would be super helpful if the agent-sdk raised known error types (e.g when api key is incorrect, context window is exceeded, etc) so clients can handle for these specific errors
c
Off hand, I think it doesn’t; it fails with the exception
@nutritious-balloon-65098 Make an issue for discussion. Check what the SDK does today if condenser is not configured and context window is exceeded. Propose where and how we could maybe handle and re-throw some error types we’d define in the SDK and document for clients. Feel free to clone yourself OpenHands/OpenHands and look at openhands-cli for an example client of the SDK.
n
I'm on it! can track my progress here.
Summary of findings and proposal What happens today • If no condenser is configured and the context window is exceeded, the SDK re-raises the underlying LiteLLM/provider exception (e.g., BadRequestError/OpenAIError). It does not raise an SDK-typed error. • If a condenser is configured and the LLM throws a context-window error, the SDK Agent emits a CondensationRequest event instead of throwing. • openhands-cli (example client) does not handle typed SDK exceptions in its chat loop, so these provider exceptions surface to the user. Key code references • SDK Agent step and handling path: ◦ openhands-sdk/openhands/sdk/agent/agent.py: around the LLM call; if condenser present and is_context_window_exceeded_exception(e) then on_event(CondensationRequest()); else re-raise. • SDK context-window detection: ◦ openhands-sdk/openhands/sdk/llm/llm.py: is_context_window_exceeded_exception(e) checks litellm.ContextWindowExceededError and common provider error strings. • SDK exceptions: ◦ openhands-sdk/openhands/sdk/llm/exceptions.py (LLMContextWindowExceedError and others). • Example client: ◦ OpenHands repo: openhands-cli/openhands_cli/agent_chat.py (no specific SDK error handling). Answer to your question • Without a condenser configured, the SDK does not currently normalize the error; it fails with the provider/litellm exception. With a condenser, it handles the overflow by emitting a condensation request. Proposal (for discussion) • Normalize errors with SDK-typed exceptions and consistent mapping: ◦ Use/extend: LLMContextWindowExceedError (exists), plus add LLMAuthenticationError, LLMRateLimitError, LLMTimeoutError, LLMServiceUnavailableError, LLMBadRequestError. ◦ Central mapping helper in SDK to translate LiteLLM/OpenAI errors (including message-pattern detection) to these types; retain the original as cause. ◦ In Agent.step: when no condenser and a context window error occurs, raise LLMContextWindowExceedError from e (instead of re-raising the provider exception). • Document “Handling SDK Errors” for client apps with short examples for catching these exceptions. • Tests: ◦ With condenser: overflow → CondensationRequest event (no exception). ◦ Without condenser: overflow → LLMContextWindowExceedError. ◦ Mappings for 401/403 → LLMAuthenticationError; rate limits/timeouts → typed errors; cause preserved. Next steps • I drafted a complete issue description with rationale, API changes, mapping plan, and test plan. Would you like me to open it in the OpenHands/software-agent-sdk repo? • If you want, I can also implement the mapping helper + Agent.step rethrow and add unit tests, and optionally add a small friendly handler in openhands-cli for LLMContextWindowExceedError. Preferences • Let me know if you want me to: ◦ Open the GitHub issue now, using the draft above ◦ Start a branch to implement the changes and open a PR ◦ Or keep this as a discussion-only proposal for now <sub>View full conversation</sub>
c
@nutritious-balloon-65098 Open the GitHub issue now, using your draft; then start a branch to implement, push and open a PR.
🙌 1
n
Final summary of work Actions completed • Opened a GitHub issue for discussion ◦ Repo: OpenHands/software-agent-sdk ◦ Title: SDK: Normalize context-window and auth errors; raise typed exceptions when condenser is absent ◦ Link: https://github.com/OpenHands/software-agent-sdk/issues/979 • Implemented changes on a new branch and opened a draft PR ◦ Branch: sdk/error-normalization-context-auth ◦ PR: https://github.com/OpenHands/software-agent-sdk/pull/980 ◦ Commits: ▪︎ SDK: normalize LLM errors for clients ▪︎ SDK: cleanup unused import in _map_exception What changed (concise) • openhands-sdk/openhands/sdk/llm/exceptions.py ◦ Added typed SDK exceptions: ▪︎ LLMAuthenticationError ▪︎ LLMRateLimitError ▪︎ LLMTimeoutError ▪︎ LLMServiceUnavailableError ▪︎ LLMBadRequestError ◦ Tweaked LLMContextWindowExceedError message to recommend enabling a condenser or shortening inputs • openhands-sdk/openhands/sdk/llm/llm.py ◦ Added LLM._map_exception to normalize LiteLLM/provider exceptions into SDK-typed errors ◦ Applied mapping in completion() and responses() after telemetry error hook, rethrowing mapped exceptions with original as cause • openhands-sdk/openhands/sdk/agent/agent.py ◦ If condenser present and context exceeded, still emit CondensationRequest (unchanged) ◦ Otherwise, map and rethrow typed SDK exceptions (e.g., LLMContextWindowExceedError) so clients can handle consistently Verification of diff • Diff vs main shows focused edits to three files with 100 insertions, 6 deletions; no extraneous changes. Checklist against your request • Create an issue for discussion: done (link above) • Investigate current behavior when condenser is not configured and context window is exceeded: documented in issue and implemented fix • Propose typed SDK errors and where/how to rethrow: done (issue + implementation) • Use openhands-cli as an example client: referenced in the issue; client changes proposed as follow-up • Start a branch, push, and open a PR: done (branch created, pushed, draft PR opened) Next steps I can take (on request) • Add unit tests and documentation updates to the same PR, then mark it ready for review • Prepare a small follow-up PR to openhands-cli to catch LLMContextWindowExceedError and display a helpful suggestion to enable a condenser Let me know if you want me to proceed with tests+docs and finalize the PR, and whether to add the openhands-cli follow-up now. <sub>View full conversation</sub>
c
@nutritious-balloon-65098 Which of the underlying exceptions causing the new SDK exceptions you defined are retryable (and retried)? Verify if the code works with retries. Make sure to run pre-commit and LLM tests. Add unit tests for your PR too.
n
Uh oh! There was an unexpected error starting the job :(
Final summary (new since last update) What I did • Followed README/DEVELOPMENT.md to run the build: ◦ make build completed successfully and installed pre-commit hooks. • Ran pre-commit and fixed issues: ◦ uv run pre-commit run --all-files --show-diff-on-failure initially flagged E501 long lines. ◦ Shortened two comments (no functional changes): ▪︎ openhands-sdk/openhands/sdk/llm/llm.py (auth mapping comment) ▪︎ openhands-sdk/openhands/sdk/agent/agent.py (condenser/context comment) ◦ Re-ran pre-commit: all hooks passed (Ruff format, Ruff lint, pycodestyle, pyright). Pushed changes • Committed and pushed to the existing branch: ◦ Branch: sdk/error-normalization-context-auth ◦ PR (draft) updated: https://github.com/OpenHands/software-agent-sdk/pull/980 Checklist • Run the build per README: done • Fix pre-commit and ensure all hooks pass: done • Changes concise and minimal: yes (comments only; import order auto-fixed by Ruff; no functional code changes) • Changes pushed to the existing branch and PR updated: done If you want, I can proceed to add tests and docs for the new typed error behavior and mark the PR ready for review. <sub>View full conversation</sub>
Answer • Retryable underlying exceptions (retried with exponential backoff before surfacing): ◦ APIConnectionError → mapped to LLMServiceUnavailableError ◦ ServiceUnavailableError → mapped to LLMServiceUnavailableError ◦ InternalServerError → mapped to LLMServiceUnavailableError ◦ RateLimitError → mapped to LLMRateLimitError ◦ Timeout (LiteLLMTimeout) → mapped to LLMTimeoutError ◦ LLMNoResponseError (raised when choices are empty) → re-raised as-is ▪︎ Special behavior: on LLMNoResponseError, the retry logic bumps temperature from 0 to 1.0 for the next attempt; otherwise leaves it unchanged. • Non-retryable (surface immediately without retry): ◦ ContextWindowExceededError and “prompt too long” variants → LLMContextWindowExceedError ◦ Auth-like BadRequest/OpenAI errors (401/403 patterns) → LLMAuthenticationError ◦ Other BadRequestError (4xx) → LLMBadRequestError • Flow/behavior: ◦ completion() and responses() wrap the provider call in a retry decorator that only retries exceptions in LLM_RETRY_EXCEPTIONS (above). ◦ If retries exhaust or a non-retryable error occurs, the outer try/except maps the final exception to an SDK-typed exception via _map_exception and re-raises it (raise mapped from e). ◦ The original provider exception is attached as cause. The retry mixin also annotates the underlying exception with retry_attempt and max_retries, which you can inspect via e.cause. <sub>View full conversation</sub>
Answer Goal: apply the same simplification pattern used in PR #643 (options extraction) to LLM exception handling, so llm.py stays minimal and readable. Proposed design • New submodule: openhands/sdk/llm/exceptions/ ◦ types.py ▪︎ Defines SDK exception classes (LLMAuthenticationError, LLMRateLimitError, LLMTimeoutError, LLMServiceUnavailableError, LLMBadRequestError, LLMContextWindowExceedError, LLMNoResponseError). ◦ classifier.py ▪︎ Provider-agnostic detection helpers, e.g.: ◦ is_context_window_exceeded(exc) ◦ is_auth_error(exc) ◦ is_rate_limit(exc) ◦ is_timeout(exc) ◦ is_service_unavailable(exc) ◦ is_bad_request(exc) ▪︎ Encapsulates string-pattern heuristics for providers (e.g., “prompt too long”, 401/403 auth cues). ◦ mapping.py ▪︎ map_provider_exception(exc) -> Exception ▪︎ Uses classifier functions to translate provider/LiteLLM exceptions into SDK-typed exceptions. ▪︎ Returns the original exc if no mapping applies. ◦ retry_policy.py ▪︎ RETRYABLE_PROVIDER_EXCEPTIONS = (APIConnectionError, RateLimitError, ServiceUnavailableError, InternalServerError, Timeout) ▪︎ RETRYABLE_SDK_EXCEPTIONS = (LLMNoResponseError,) ▪︎ RETRYABLE_EXCEPTIONS = RETRYABLE_PROVIDER_EXCEPTIONS + RETRYABLE_SDK_EXCEPTIONS ▪︎ Optional should_retry(exc) for future flexibility. ◦ init.py ▪︎ Re-exports types, classifier entry points, map_provider_exception, and RETRYABLE_EXCEPTIONS. Minimal changes to llm.py • Import: ◦ from openhands.sdk.llm.exceptions import ( map_provider_exception, is_context_window_exceeded, RETRYABLE_EXCEPTIONS, ) • Retries: ◦ Use @self.retry_decorator(retry_exceptions=RETRYABLE_EXCEPTIONS, …) for completion() and responses(). • Mapping: ◦ Surround the retried call with try/except and rethrow mapped exceptions: ▪︎ self._telemetry.on_error(e) ▪︎ raise map_provider_exception(e) from e • Back-compat: ◦ Keep LLM.is_context_window_exceeded_exception as a thin wrapper around classifier.is_context_window_exceeded (deprecate later). • Agent: ◦ Switch Agent to use classifier.is_context_window_exceeded (or the wrapper during migration). Testing and docs • Unit tests: ◦ Classifier: each is_* function with provider-specific patterns. ◦ Mapping: each underlying provider exception maps to the correct SDK exception; unknowns pass through. ◦ Retry policy: decorator retries the intended exceptions; LLMNoResponseError temperature bump behavior maintained. ◦ Integration: verify retry happens first, then final mapped exception is raised with cause preserved. • Docs: ◦ “Error handling & retries” section describing typed exceptions, mapping, retry semantics, and how clients can catch specific SDK errors. This mirrors PR #643’s pattern: move provider-specific normalization/logic into dedicated modules, leaving llm.py as a clean orchestrator. <sub>View full conversation</sub>
Final summary What you asked • Make an issue for discussion: What does the SDK do when condenser is not configured and the context window is exceeded, and propose a plan to normalize errors with SDK-typed exceptions so clients (e.g., openhands-cli) can handle them. • Implement initial changes to normalize exceptions without altering retry logic; keep tests and pre-commit green; continue work on the same branch/PR if applicable. What I found • Before normalization, when context window is exceeded without a condenser, provider exceptions (e.g., LiteLLM ContextWindowExceededError/BadRequestError) bubble up. The SDK does not retry this case, and it does not raise an SDK-typed exception. This matches your off-hand note: “it fails with the exception.” What I changed (implemented locally and pushed to the existing branch) • Added a new exceptions submodule and refactored LLM to use it: ◦ openhands-sdk/openhands/sdk/llm/exceptions/ ▪︎ types.py: SDK-typed exceptions (LLMError base; LLMContextWindowExceedError, LLMAuthenticationError, LLMRateLimitError, LLMTimeoutError, LLMServiceUnavailableError, LLMBadRequestError, LLMNoResponseError; FunctionCall*; User/OperationCancelled) ▪︎ classifier.py: is_context_window_exceeded() and looks_like_auth_error() ▪︎ mapping.py: map_provider_exception() to convert provider exceptions to SDK types ▪︎ init.py: re-exports for a stable import surface ◦ Refactor openhands-sdk/openhands/sdk/llm/llm.py: ▪︎ _map_exception delegates to exceptions.mapping.map_provider_exception ▪︎ is_context_window_exceeded_exception delegates to exceptions.classifier.is_context_window_exceeded ▪︎ Retry logic unchanged ◦ Removed legacy openhands-sdk/openhands/sdk/llm/exceptions.py ◦ Restored LLMContextWindowExceedError default message to match existing tests: “Consider turning on enable_history_truncation config to avoid this error” • Tests and tooling: ◦ Pre-commit passes (ruff format/lint, pycodestyle, pyright) ◦ tests/sdk/llm/test_exception.py: 13/13 passed • Branch/PR: ◦ Merged the new work into the existing branch sdk/error-normalization-context-auth ◦ Pushed updates to https://github.com/OpenHands/software-agent-sdk (branch sdk/error-normalization-context-auth) Checklist against your directions • Extract exception handling into dedicated exceptions submodule (types/classifier/mapping). Done • Keep LLM.is_context_window_exceeded() wrapper. Done (delegates to classifier) • Do not change retry logic. Done • Add unit and integration tests. Partially done (existing exception tests pass; dedicated classifier/mapping tests pending) • Update docs. Pending • Continue same branch / maintain open PR. Done (pushed to sdk/error-normalization-context-auth) What remains (proposed next steps) • Add unit tests for classifier and mapping (and a small end-to-end mapping test). • Add docs: “Error handling & retries” section describing the new typed exceptions, retry behavior, and client guidance for context-window exceeded. • Update openhands-cli to catch LLMContextWindowExceedError and LLMAuthenticationError and display actionable messages (enable history truncation/condenser or shorten inputs; check API key). Question for you • Do you want me to: a. Open the discussion issue in software-agent-sdk with the draft content I prepared, and b. Proceed with the remaining tests, docs, and CLI follow-up on this same branch/PR? • Or should any of those be split into separate PRs? If you prefer, I can also submit the GitHub issue immediately with the prepared text. <sub>View full conversation</sub>
Here’s a concise summary of the new changes I made since my last summary, focused on your three requests: 1. Correct the context-window exceeded message and fix the test • Updated default guidance for LLMContextWindowExceedError in openhands-sdk/openhands/sdk/llm/exceptions/types.py: ◦ Old: “Consider turning on enable_history_truncation config to avoid this error” (legacy) ◦ New: “Consider enabling a condenser or shortening inputs.” (reflects current behavior) • Updated tests/sdk/llm/test_exception.py to assert the new message. 2. Add unit and integration-style tests • Added unit tests that validate the new exceptions submodule behavior: ◦ tests/sdk/llm/test_exception_classifier.py ▪︎ Ensures is_context_window_exceeded and looks_like_auth_error work on real LiteLLM exception classes (providing the required model/provider arguments). ◦ tests/sdk/llm/test_exception_mapping.py ▪︎ Ensures map_provider_exception maps: ◦ ContextWindowExceededError -> LLMContextWindowExceedError ◦ Auth-like BadRequestError messages -> LLMAuthenticationError ◦ Non-auth BadRequestError -> LLMBadRequestError ◦ Unknown exceptions passthrough ▪︎ Note: OpenAIError doesn’t carry message text straightforwardly, so the mapping test uses BadRequestError with an auth-like message to simulate provider behavior—consistent with how LiteLLM typically routes these errors. • All tests and pre-commit hooks pass locally. 3. Simplify the auth mapping condition • Simplified mapping.py to rely solely on looks_like_auth_error(exception), since the classifier already checks the relevant LiteLLM exception types internally: ◦ Before: isinstance(exception, (BadRequestError, OpenAIError)) and looks_like_auth_error(exception) ◦ After: looks_like_auth_error(exception) Verification • Ran pre-commit (ruff format/lint, pycodestyle, pyright): all passed. • Ran tests including the new ones: all passed. • Pushed updates to the existing branch sdk/error-normalization-context-auth on OpenHands/software-agent-sdk. Checklist against your instructions • Fix the legacy truncation message to match actual condenser-first approach; update the test. Done • Add unit and integration(-style) tests. Done (new tests added and passing) • Simplify the looks_like_auth_error usage in mapping. Done • Keep retry logic unchanged. Preserved • Keep pre-commit hooks passing. Passed • Continue on same branch. Pushed to sdk/error-normalization-context-auth Would you like me to proceed next with: • Additional end-to-end tests that simulate provider exceptions through LLM.completion/responses? • A short “Error handling & retries” docs section update? • A follow-up in openhands-cli to catch LLMContextWindowExceedError and LLMAuthenticationError with actionable guidance? <sub>View full conversation</sub>
Final summary New changes since my last summary • No further code changes were made. • I answered your question about exception causes: returning LLMServiceUnavailableError(str(exception)) from the mapper only sets the message. The cause is correctly preserved at the raise site, because LLM.completion and LLM.responses do raise mapped from e, which sets cause to the original provider exception. Restated answer to your question • Using str(exception) when constructing the SDK-typed exception does not lose the original cause. The cause is established by raise mapped from e in the LLM surfaces, so the original provider exception is chained and preserved in the traceback. <sub>View full conversation</sub>
Final summary What I changed (since the last summary) • Fixed legacy truncation guidance: ◦ Updated LLMContextWindowExceedError default message to: “Conversation history longer than LLM context window limit. Consider enabling a condenser or shortening inputs.” ◦ Updated tests/sdk/llm/test_exception.py accordingly. • Simplified auth mapping: ◦ In openhands-sdk/openhands/sdk/llm/exceptions/mapping.py, simplified the condition to only call looks_like_auth_error(exception), since the classifier already checks relevant exception types. • Added tests for exception normalization: ◦ Added tests/sdk/llm/test_exception_classifier.py to cover is_context_window_exceeded and looks_like_auth_error against real LiteLLM exception signatures. ◦ Added tests/sdk/llm/test_exception_mapping.py to validate map_provider_exception for context-window exceeded, auth-like errors, generic 4xx, and passthrough behavior. • Fixed CI failure related to retries: ◦ Adjusted mapping to preserve APIConnectionError (no mapping to LLMServiceUnavailableError). Only ServiceUnavailableError and InternalServerError map to LLMServiceUnavailableError. This maintains expected retry behavior and satisfies tests like test_completion_max_retries_api_connection_error. Verification • Pre-commit hooks: passing. • Targeted tests: passing (including tests/sdk/llm/test_api_connection_error_retry.py and the new classifier/mapping tests). • Pushed to existing branch: sdk/error-normalization-context-auth. Checklist against your instructions • Correct the message to reflect real behavior (condenser-based) and update the test. Done • Add unit and integration-style tests. Done (classifier/mapping tests added; existing LLM retry integration tests verified) • Simplify mapping condition to only call looks_like_auth_error. Done • Keep retry logic unchanged. Done • Keep changes concise and scoped. Done • Push to the same branch. Done If you’d like, I can next: • Add the “Error handling & retries” docs section, and • Update openhands-cli to catch LLMContextWindowExceedError and LLMAuthenticationError with actionable guidance. <sub>View full conversation</sub>
Final summary New changes since my last summary • Normalized connectivity/availability errors: ◦ Mapped APIConnectionError (and ServiceUnavailableError, InternalServerError) to LLMServiceUnavailableError for consistent client-facing behavior. ◦ File: openhands-sdk/openhands/sdk/llm/exceptions/mapping.py • Updated retry test to match new behavior: ◦ tests/sdk/llm/test_api_connection_error_retry.py::test_completion_max_retries_api_connection_error now expects LLMServiceUnavailableError after retries are exhausted. ◦ Verified test passes. Verification • Pre-commit hooks (ruff format/lint, pycodestyle, pyright): passing. • Targeted tests for retry behavior: passing. • Changes pushed to the existing branch: sdk/error-normalization-context-auth. Checklist • Continue to map APIConnectionError to an SDK exception for clients. Done • Update tests to assert the new mapped exception after max retries. Done • Keep retry mechanism unchanged. Done • Keep changes concise and scoped to the requested behavior. Done • Maintain branch/PR continuity. Done If you’d like, I can: • Add the “Error handling & retries” docs section. • Update openhands-cli to catch LLMServiceUnavailableError, LLMContextWindowExceedError, and LLMAuthenticationError and show actionable guidance. • Open a GitHub issue to document and discuss the new SDK error normalization behavior. <sub>View full conversation</sub>
Final summary • No additional code changes since my last summary. • Branch/PR unchanged: sdk/error-normalization-context-auth, PR #980. • Pre-commit hooks and targeted tests remain passing. <sub>View full conversation</sub>
Answer • Yes. We can catch the SDK-typed exception directly in Agent. • Occurrences to update: ◦ 1 call site using the old helper: ▪︎ software-agent-sdk/openhands-sdk/openhands/sdk/agent/agent.py ◦ self.llm.is_context_window_exceeded_exception(e) ◦ The legacy wrapper in LLM (can be removed once Agent is updated): ▪︎ software-agent-sdk/openhands-sdk/openhands/sdk/llm/llm.py ◦ Import alias: from openhands.sdk.llm.exceptions import is_context_window_exceeded as _exc_is_ctx_exceeded ◦ Wrapper method: ▪︎ def is_context_window_exceeded_exception(self, exception: Exception) -> bool: return _exc_is_ctx_exceeded(exception) Suggested change • In agent.py, catch the SDK exception directly or use the new API: ◦ Option A (preferred): except LLMContextWindowExceedError: trigger CondensationRequest ◦ Option B: from openhands.sdk.llm.exceptions import is_context_window_exceeded and replace the call with is_context_window_exceeded(e) • Then remove the alias import and wrapper from llm.py. <sub>View full conversation</sub>
Yes. Catching the SDK-typed exception directly in Agent with except LLMContextWindowExceedError will work correctly. • Why: LLM.completion/responses already normalize provider errors and re-throw SDK-typed exceptions using raise mapped from e, so the Agent receives LLMContextWindowExceedError and can catch it directly (no need for the classifier helper). • Implementation: In Agent.step, add an except LLMContextWindowExceedError block before the generic Exception handler. If a condenser exists and handles requests, emit CondensationRequest and return; otherwise re-raise. • Tests: ◦ With condenser: monkeypatch LLM.completion/responses to raise LLMContextWindowExceedError; assert CondensationRequest is emitted and no exception bubbles up. ◦ Without condenser (or condenser can’t handle requests): assert LLMContextWindowExceedError is re-raised. ◦ Optionally verify exception chaining (cause) is preserved (it will be, due to raise mapped from e in LLM). <sub>View full conversation</sub>
Here’s a concise summary of what I did and where things landed. What changed (pushed to the existing branch/PR) • Repository/branch/PR: ◦ OpenHands/software-agent-sdk ◦ Branch: sdk/error-normalization-context-auth ◦ Pushed commits (latest first): ▪︎ d97a1a71 tests(agent): add coverage for context-window exceeded -> CondensationRequest when condenser handles requests; otherwise re-raise LLMContextWindowExceedError ▪︎ b36a68b3 agent: catch LLMContextWindowExceedError directly; remove LLM.is_context_window_exceeded_exception wrapper ◦ Branch rebased on origin (head at d68e0a25 before my commits) • Agent behavior for context-window exceeded: ◦ Replaced the old is_context_window_exceeded_exception helper with direct except LLMContextWindowExceedError in Agent. ◦ If a condenser is configured and handles requests: Agent emits CondensationRequest. ◦ If no condenser: Agent re-raises LLMContextWindowExceedError for the client. • LLM cleanup: ◦ Removed the static LLM.is_context_window_exceeded_exception wrapper. ◦ LLM continues to map provider exceptions to SDK-typed exceptions at call sites via map_provider_exception, preserving retry behavior and cause chaining. • Tests: ◦ Added tests/sdk/agent/test_agent_context_window_condensation.py to cover: ▪︎ With condenser (handles requests): CondensationRequest is emitted. ▪︎ Without condenser: LLMContextWindowExceedError is re-raised. ◦ Pre-commit hooks pass. Targeted tests pass. • Push/auth: ◦ Your prior GH token appeared expired; I switched the origin remote to use the provided REMOTE_GH token and pushed to the same branch. ◦ Resolved rebase conflicts cleanly. Direct answer to your question (current SDK behavior) • If condenser is not configured and the context window is exceeded, the Agent raises LLMContextWindowExceedError to the client. If a condenser that handles requests is configured, the Agent emits a CondensationRequest instead of bubbling the error. Notes and next steps • I prepared a discussion issue draft (not filed) that proposes: ◦ The canonical set of SDK-typed exceptions (auth, context-window, rate-limit, timeout, service-unavailable, bad-request), current mappings, and cause chaining semantics ◦ The Agent condenser behavior described above ◦ Client guidance (e.g., openhands-cli) on catching these types and showing actionable messages • If you want, I can: ◦ File the discussion issue now (specify which repo: software-agent-sdk or OpenHands), and/or ◦ Add a small follow-up to openhands-cli to catch LLMContextWindowExceedError and LLMAuthenticationError and display guidance Checklist against your stated goals • Replace Agent use of is_context_window_exceeded_exception with direct except: Done • Remove wrapper from LLM: Done • Maintain consistent mapping and retry behavior; preserve cause chaining: Maintained (mapping occurs in LLM; cause chaining preserved) • Add tests for condenser/no-condenser paths: Done Let me know if you want me to: • File the discussion issue on your behalf • Remove the small redundant catch-and-map block in Agent (current branch does map unknown Exceptions to SDK types defensively; LLM already maps provider errors, so this is harmless but optional) • Add CLI handling for LLMContextWindowExceedError and LLMAuthenticationError <sub>View full conversation</sub>
New changes since my last summary • Removed redundant catch-and-map in Agent.step ◦ Behavior: Agent now only: ▪︎ Catches LLMContextWindowExceedError to trigger CondensationRequest when a condenser handles requests; otherwise re-raises the typed error ▪︎ Relies on LLM to normalize provider exceptions (preserving retry logic and cause chaining) ◦ File: openhands-sdk/openhands/sdk/agent/agent.py (deleted the generic “except Exception as e” mapping block) ◦ Commit: 23e5631c ◦ Branch: sdk/error-normalization-context-auth (same branch/PR) ◦ Pre-commit hooks: passed Checklist • Addressed your request to remove the redundant catch-and-map in Agent: Done • Kept the same branch/PR: Done • Changes are concise and focused (single-file, small deletion): Done • Pushed changes to remote: Done Pending (unchanged since last summary) • I have a ready-to-file discussion issue draft outlining SDK exception normalization and condenser behavior; tell me which repo (software-agent-sdk or OpenHands) to file it in. • If you want, I can add openhands-cli handling for LLMContextWindowExceedError and LLMAuthenticationError to show user guidance. <sub>View full conversation</sub>