Skip to content

Refactor error handling and fix state persistence in LlmAgent#144

Merged
dewitt merged 4 commits intomainfrom
pr/5-error-handling
Feb 24, 2026
Merged

Refactor error handling and fix state persistence in LlmAgent#144
dewitt merged 4 commits intomainfrom
pr/5-error-handling

Conversation

@dewitt
Copy link
Copy Markdown
Collaborator

@dewitt dewitt commented Feb 13, 2026

This PR refactors error handling and state persistence in LlmAgent to support robust Human-in-the-Loop (HITL) and client-side tool execution flows.

Key Changes:

  • Robust Error Handling: Updates runAndHandleError to support native Error objects and ensures all exceptions (including those in post-processing or function execution) are caught and yielded as standardized error events.
  • State Persistence: Fixes a bug in generateRequestConfirmationEvent to ensure actions (including stateDelta) are correctly persisted when the agent suspends for tool confirmation.
  • Explicit Suspension: Implements logic to respect pauseOnToolCalls in the agent loop, setting endInvocation = true to return control to the host immediately after a tool call or confirmation request.
  • Refactored Testing: Changes callLlmAsync and runAndHandleError to protected visibility and uses a TestLlmAgent subclass to enable strictly typed unit testing without any casts.

Reference: docs/adk-ts-improvements.md

Fixes #143.

@dewitt dewitt force-pushed the pr/5-error-handling branch from f60767c to 8f4e296 Compare February 24, 2026 00:02
@dewitt dewitt force-pushed the pr/5-error-handling branch from 1d3b0ec to 1829573 Compare February 24, 2026 00:58
@dewitt dewitt merged commit e2cd372 into main Feb 24, 2026
6 checks passed
@dewitt dewitt deleted the pr/5-error-handling branch February 24, 2026 01:08
dewitt added a commit that referenced this pull request Feb 25, 2026
* Refactor error handling and fix state persistence in LlmAgent

Fixes #143

* chore: include PR #140 and #136 dependencies for CI

* chore: remove stale agent_event.ts mock dependency

* test: remove any casts and use TestLlmAgent for cleaner testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor error handling and fix state persistence in LlmAgent

2 participants