Converts the ad-hoc executeToolPhase → runAssistantTurn recursion into an explicit while (stepNumber < effectiveCap) loop. A step is one stream-and- tool-execute iteration; the loop terminates on non-tool finish, step-cap hit, doom-loop, budget exhaustion, abort, or synthesis success. MAX_STEPS = 200 hard ceiling (4x old effective limit from budget). Per-agent steps: field in AGENTS.md frontmatter sets tighter caps (Refactorer: 5, Architect: 20, others: unset = bounded only by MAX_STEPS). Resolution: effectiveCap = Math.min(agent.steps ?? Infinity, MAX_STEPS). executeToolPhase no longer recurses — returns ToolPhaseResult struct (action: 'continue' | 'paused' | 'synthesis_done') so the caller decides whether to continue or break. steps: 0 handled as "no tool calls allowed" via runTextOnlyTurn (one text-only stream phase, tool calls ignored with warn log). Step-cap hits produce a sentinel summary (reuses cap_hit kind so CapHitSentinel.tsx renders without frontend changes; text distinguishes "Step limit reached" from "Tool budget exhausted"). Doom-loop check migrated to top of loop body — same predicate, same threshold (3), break instead of return. step_start parts are in the schema CHECK but not emitted as message_parts — writing before the stream phase creates a sequence-0 collision with partsFromAssistantMessage. Structured log line emitted instead. Adversarial review caught the collision pre-deploy. 332/332 server tests passing. No frontend changes. No schema changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
23 lines
737 B
TypeScript
23 lines
737 B
TypeScript
// v1.12.4: re-export shim. Outside callers (apps/server/src/index.ts and the
|
|
// vitest inference tests) import from './services/inference/index.js'. The
|
|
// directory is now the public surface; turn.ts holds runAssistantTurn /
|
|
// runInference / createInferenceRunner while the other inference/*.ts files
|
|
// stay implementation-private.
|
|
|
|
export {
|
|
createInferenceRunner,
|
|
MAX_STEPS,
|
|
runAssistantTurn,
|
|
runInference,
|
|
} from './turn.js';
|
|
export type {
|
|
FramePublisher,
|
|
InferenceContext,
|
|
InferenceFrame,
|
|
StreamResult,
|
|
TurnArgs,
|
|
} from './turn.js';
|
|
export type { ToolPhaseResult } from './tool-phase.js';
|
|
export { detectDoomLoop, DOOM_LOOP_THRESHOLD } from './sentinels.js';
|
|
export { buildMessagesPayload } from './payload.js';
|