fix(kernel,server,workflow): per-stage retry budget, sane freestyle budget, tail /events
Three defects surfaced by a live headless freestyle_planning run (all made a long execution workflow fail or stall in ways invisible to a REST operator): 1. retryCount was session-global (DefaultOrchestrationReducer): TransitionExecuted updated currentStageId but never reset retryCount, while shouldRetry gates on it per-stage. An early stage that burned its 3 retries starved every later stage of its own — the next stage's first *retryable* failure went terminal. Reset retryCount on stage entry; back-edge loops stay bounded by the separate refinementIterations counter. Regression test added. 2. Freestyle stages ran at StageConfig's 4096-token default (ExecutionPlanCompiler never set a budget) vs 16384-32768 for static role_pipeline stages. A tool-heavy stage truncated its context every round, evicting the file_read results it just gathered, so it re-read forever and never accumulated enough to write. Set 16384. 3. GET /events returned the OLDEST `limit` events (readFrom(0) then take): for a session past `limit` events the tail — including a pending ApprovalRequested — was invisible to a headless/REST poller, the exact caller POST /approve serves. Default now tails; explicit fromSeq still paginates forward.
This commit is contained in:
+9
@@ -15,6 +15,14 @@ import com.fasterxml.jackson.module.kotlin.readValue
|
||||
|
||||
private const val TERMINAL = "done"
|
||||
|
||||
// Freestyle plans don't specify a per-stage token budget, so without this every compiled stage
|
||||
// inherits StageConfig's 4096 default — 1/8th of what the static role_pipeline execution stages
|
||||
// use (16384–32768). At 4096 a tool-heavy stage (scaffold/implement) truncates its context every
|
||||
// round, evicting the file_read results the model just gathered, so it re-reads forever and never
|
||||
// accumulates enough to write. Match the static execution baseline. (gemma ctx is 32768, so this
|
||||
// leaves ample headroom for completion.)
|
||||
private const val DEFAULT_STAGE_TOKEN_BUDGET = 16384
|
||||
|
||||
class ExecutionPlanCompiler(
|
||||
private val registry: ArtifactKindRegistry,
|
||||
// Names of every registered tool. A stage that references a tool the runtime can't resolve
|
||||
@@ -55,6 +63,7 @@ class ExecutionPlanCompiler(
|
||||
needs = s.needs.map { ArtifactId(it) }.toSet(),
|
||||
allowedTools = s.tools.toSet(),
|
||||
writeManifest = writeManifest,
|
||||
tokenBudget = DEFAULT_STAGE_TOKEN_BUDGET,
|
||||
metadata = mapOf("promptInline" to s.prompt),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user