Skip to content

refactor: extract callModel, unify tool handlers, add sessionCompactor#2761

Open
dgageot wants to merge 4 commits into
docker:mainfrom
dgageot:runtime/extract-collaborators
Open

refactor: extract callModel, unify tool handlers, add sessionCompactor#2761
dgageot wants to merge 4 commits into
docker:mainfrom
dgageot:runtime/extract-collaborators

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented May 11, 2026

Three runtime refactors stacked on #2759 and #2760:

  1. Extract callModel method — Pulls the before-hooks → transforms → LLM call → error handling → after-hooks pipeline out of runTurn into a standalone callModel method.

  2. Unify tool handler registration — Removes ToolHandlerFunc type. Built-in handlers now match toolexec.ToolHandler directly, eliminating the per-batch adapter loop in processToolCalls.

  3. sessionCompactor collaborator — Moves compaction logic (previously scattered across 4 files) into a self-contained sessionCompactor struct.

Depends on #2759 and #2760. Pure refactor, no behaviour change.

@dgageot dgageot requested a review from a team as a code owner May 11, 2026 16:46
@docker-agent
Copy link
Copy Markdown

PR Review Failed — The review agent encountered an error and could not complete the review. View logs.

@dgageot dgageot force-pushed the runtime/extract-collaborators branch from 112cb2e to 448ca8a Compare May 11, 2026 18:52
dgageot added 4 commits May 11, 2026 21:39
…ndler

Remove ToolHandlerFunc type and the per-batch adapter loop in
processToolCalls. Built-in handlers (transfer_task, handoff,
change_model, revert_model, run_skill) now match toolexec.ToolHandler
directly and access events through r.toolSink, set for the duration of
each processToolCalls call.
Move compactWithReason, compactIfNeeded, preCompactSourceFor, and
joinPrompts into a sessionCompactor struct. The LocalRuntime holds a
*sessionCompactor and delegates all compaction calls to it. This
concentrates compaction reasoning (previously spread across runtime.go,
loop.go, loop_steps.go, and session_compaction.go) in one place.
@dgageot dgageot force-pushed the runtime/extract-collaborators branch from 448ca8a to b3e7935 Compare May 11, 2026 19:40
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.

2 participants