fix: handle max turns properly and add missing MultiEditToolConfig - #1007
Conversation
|
@infer CI is failing - can you fix this? use /go /ponytail:ponytail |
|
Model: Todos
Pull Request✅ Infer Result: SuccessAll CI checks pass. Let me finalize. All CI checks pass now. Here's a summary of what was done: SummaryRoot cause: The PR's changes in Fix: Added the missing // MultiEditToolConfig contains multi-edit-specific tool settings
type MultiEditToolConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled"`
RequireApproval *bool `yaml:"require_approval,omitempty" mapstructure:"require_approval,omitempty"`
}CI results (all pass): build, lint, vet, test, e2e, postgres, CodeQL, Analyze (go/js/actions) Model: Tokens: 1,154,402 in · 4,743 out · 1,159,145 total (21 requests) Tool calls: 30 total · 87% success rate TracesStats
|
The MultiEditToolConfig type was referenced in ToolsConfig and IsApprovalRequired but never defined, causing a typecheck compilation error. Add the minimal struct with Enabled and RequireApproval fields, matching the pattern of other tool config types.
|
@infer can you update the title and the body of this PR? |
|
Model: Todos
Pull Request✅ Infer Result: SuccessDone. PR #1007 has been updated:
Model: Tokens: 203,058 in · 1,553 out · 204,611 total (8 requests) Tool calls: 9 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
|
@infer Can you address these, use /go /ponytail:ponytail Verdict: correct direction, but not ready to mergeCI is green and the diff is small, but I found two blocking issues. 1.
|
|
Model: Todos
Pull Request✅ Infer Result: SuccessAll changes are committed and pushed to PR #1007. Here's a summary of what was done: Changes made1. Register
|
Adds a default MultiEditToolConfig entry in DefaultConfig(), mirroring Edit, so Viper registers the key and INFER_TOOLS_MULTI_EDIT_REQUIRE_APPROVAL works through environment variables.
|
@infer Can you fix these nit-picking:
|
|
Model: Todos
Pull Request✅ Infer Result: SuccessBoth nit-picking issues are fixed and pushed to PR #1007. Here's what changed: 1.
|
…max-turns path Set the error variable and fall through to the shared post-session block instead of duplicating dispatchHooks + waitForBackgroundTasks calls. Saves 4 lines.
Callers (e.g. infer-action) can now distinguish turn exhaustion (2) from success (0) and failure (1). Documents the exit-code contract in the agent command help and collapses the duplicate max-turns log lines.
|
🎉 This PR is included in version 0.160.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #1006
Summary
Fixes two issues found while investigating #1006:
Agent max-turns handling - When the agent reaches its maximum turn limit, it now properly dispatches post-session hooks, waits for background tasks, and returns a descriptive error. The
agentSessionOutcomefunction maps themax_turns_reachederror tostopped_early(instead offailed), so telemetry correctly reflects the outcome.Missing MultiEditToolConfig - The
MultiEdittool was missing its config struct definition and approval wiring inconfig.go, causing a nil pointer or missing approval check when the tool was used. Added theMultiEditToolConfigtype and its entry inIsApprovalRequired.Changes
cmd/agent.go- Dispatch hooks and wait for background tasks on max turns; return a proper error; map it tostopped_earlyin telemetry outcomeconfig/config.go- AddMultiEditToolConfigstruct and wire it intoToolsConfigandIsApprovalRequiredExit-code contract (added after review)
infer agentnow exits with a dedicated code when the turn budget runs out, so callers like infer-action can tell exhaustion apart from failure:agent.max_turnsexhausted before the task completedTelemetry maps max-turns to
stopped_early;session_statsand theagent_errorline are still emitted on the exhaustion path. Verified end-to-end against the mock gateway (INFER_AGENT_MAX_TURNS=3→ exit 2; normal completion → exit 0).