Skip to content

Add files via upload#5776

Closed
Paramveersingh-S wants to merge 1 commit into
earendil-works:mainfrom
Paramveersingh-S:main
Closed

Add files via upload#5776
Paramveersingh-S wants to merge 1 commit into
earendil-works:mainfrom
Paramveersingh-S:main

Conversation

@Paramveersingh-S

Copy link
Copy Markdown

PR: Fix Agent Wedge on Unresponsive Streams & Tool Executions

Fixes Issue #2381

Description

This PR addresses the issue where pi-agent-core can hang indefinitely if the underlying LLM provider stream stops yielding events without closing, or if a tool's execute() promise never resolves.

This introduces configurable timeouts for both boundaries:

  • AgentLoopConfig.streamTimeoutMs: Timeouts the stream if no event is yielded. (Default 5 mins).
  • AgentLoopConfig.toolTimeoutMs: Timeouts the overall tool execution. (Default 10 mins).
  • AgentTool.timeoutMs: Override for specific tools.

If a timeout occurs, the stream or tool execution throws a timed-out error, allowing the loop to gracefully report the error to the UI and either continue or exit instead of hanging dead.

Changes

  • Modified packages/agent/src/types.ts to add streamTimeoutMs and toolTimeoutMs to AgentLoopConfig, and timeoutMs to AgentTool.
  • Modified packages/agent/src/agent-loop.ts to use Promise.race for timeouts on the assistant stream iterator.next() and tool execute().
  • Added a regression test asserting the fail-closed behavior on timeout.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first.

Maintainers review auto-closed issues daily. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Jun 15, 2026
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.

1 participant