Skip to content

Comments

feat: add turn-logic module with parallel tool execution and fix agent timeout#207

Closed
ghost wants to merge 1 commit intomainfrom
unknown repository
Closed

feat: add turn-logic module with parallel tool execution and fix agent timeout#207
ghost wants to merge 1 commit intomainfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Jan 5, 2026

Summary

  • Add new turn-logic.ts module implementing Claude Code / Anthropic SDK agentic loop pattern
  • Increase default agent.wait timeout from 30 seconds to 10 minutes to allow multi-turn agent loops

Changes

New Turn Logic Module (src/agents/turn-logic.ts)

  • executeTurnLoop() - Core agentic loop with parallel tool execution
  • streamingTurnLoop() - Async generator version for real-time streaming events
  • TurnStateMachine - State machine for human-in-the-loop workflows
  • withTimeout() - Per-tool timeout helper with configurable defaults
  • Utility functions: shouldContinue(), isTerminal(), extractToolUses(), etc.

Key Features

  • Parallel tool execution - Multiple tools run concurrently via Promise.all()
  • Per-tool timeouts - Configurable timeouts prevent hanging tools from blocking the loop
  • max_tokens continuation - Automatically continues when response is truncated
  • Stop reason handling - Properly handles end_turn, tool_use, max_tokens, etc.
  • Configurable limits - maxTurns, maxContinuations prevent infinite loops

Timeout Fix

  • Changed default agent.wait timeout from 30s to 600s (10 minutes)
  • This allows multi-turn agent interactions to complete without timing out

Testing

  • 30 comprehensive unit tests covering all functionality
  • All tests passing
  • Build passes

Related

Future Work

The turn-logic module is not yet integrated into the main agent runner (pi-embedded-runner.ts). This PR provides the foundation for future integration.

@steipete
Copy link
Contributor

steipete commented Jan 5, 2026

Thanks! Will So far we stayed close to pi's agentic loop - need to read up more here and sync up with Mario... this should be in the pi layer and not in a consumer. What issues did you encounter?

These are two files and not wired up to the actual loop - how did you test this?

@steipete steipete added the question Further information is requested label Jan 5, 2026
@steipete steipete marked this pull request as draft January 5, 2026 03:05
@ghost
Copy link
Author

ghost commented Jan 5, 2026

Closing this PR - the turn-logic module is not wired up to the actual agent runner. The Pi agent uses @mariozechner/pi-coding-agent library which handles the agentic loop internally via session.prompt(). This code is dead/unused.

The only useful change was the timeout bump (30s → 600s), but that doesn't justify shipping 1400 lines of dead code.

Will revisit if/when we need to replace or extend the Pi library's internal loop.

@ghost ghost closed this Jan 5, 2026
dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 7, 2026
…ross 13 files) (openclaw#207)

Cover all new V2 modules: event normalizer, gates/budget, sanitize/redact,
phenomenology (taxonomy, prompt, heuristic), artifacts collector, kit builder
and resolver, retrieve (intent, ranker, vector-adapter), reconstitution
pack-builder, and fanout dispatcher. Export renderKit from resolver for
testability.

https://claude.ai/code/session_01Ko4xrCYytJBNW5VAxzfemE

Co-authored-by: Claude <[email protected]>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant