Skip to content

fix: handle max turns properly and add missing MultiEditToolConfig - #1007

Merged
edenreich merged 5 commits into
mainfrom
fix/issue-1006
Aug 4, 2026
Merged

fix: handle max turns properly and add missing MultiEditToolConfig#1007
edenreich merged 5 commits into
mainfrom
fix/issue-1006

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Resolves #1006

Summary

Fixes two issues found while investigating #1006:

  1. 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 agentSessionOutcome function maps the max_turns_reached error to stopped_early (instead of failed), so telemetry correctly reflects the outcome.

  2. Missing MultiEditToolConfig - The MultiEdit tool was missing its config struct definition and approval wiring in config.go, causing a nil pointer or missing approval check when the tool was used. Added the MultiEditToolConfig type and its entry in IsApprovalRequired.

Changes

  • cmd/agent.go - Dispatch hooks and wait for background tasks on max turns; return a proper error; map it to stopped_early in telemetry outcome
  • config/config.go - Add MultiEditToolConfig struct and wire it into ToolsConfig and IsApprovalRequired

Exit-code contract (added after review)

infer agent now exits with a dedicated code when the turn budget runs out, so callers like infer-action can tell exhaustion apart from failure:

Code Meaning
0 task completed
1 run failed
2 agent.max_turns exhausted before the task completed

Telemetry maps max-turns to stopped_early; session_stats and the agent_error line 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).

@edenreich

Copy link
Copy Markdown
Contributor

@infer CI is failing - can you fix this? use /go /ponytail:ponytail

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Model: ollama_cloud/deepseek-v4-flash · View Job

Todos

  • Understand the current state: diff, CI failures, and existing changes
  • Fix CI failures - add missing MultiEditToolConfig type
  • Run precommit checks and push

Pull Request

#1007

✅ Infer Result: Success

All CI checks pass. Let me finalize.

All CI checks pass now. Here's a summary of what was done:

Summary

Root cause: The PR's changes in config/config.go referenced MultiEditToolConfig in the ToolsConfig struct and IsApprovalRequired function, but the type was never defined. This caused a typecheck compilation error that made lint and vet CI checks fail.

Fix: Added the missing MultiEditToolConfig type definition in config/config.go (6 lines), following the same minimal pattern as other tool config types (DeleteToolConfig, TodoWriteToolConfig, etc.):

// 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: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 9m 44s

Tokens: 1,154,402 in · 4,743 out · 1,159,145 total (21 requests)

Tool calls: 30 total · 87% success rate

Traces
Session: 1785845385-0f0fcc10

session (standard, success)                                        9m43s
├── chat ollama_cloud/deepseek-v4-flash                             2.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.4s
│       ╰── HTTP POST [inference-gateway]                           2.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.4s
│               ╰── HTTP POST [inference-gateway]                   2.4s
├── execute_tool TodoWrite call_mdip8pdd                           114µs
├── chat ollama_cloud/deepseek-v4-flash                             2.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.0s
│       ╰── HTTP POST [inference-gateway]                           2.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.0s
│               ╰── HTTP POST [inference-gateway]                   2.0s
├── execute_tool Bash call_vp83voay                                  4ms
├── execute_tool Bash call_np79md59                                  6ms
├── chat ollama_cloud/deepseek-v4-flash                             3.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.1s
│       ╰── HTTP POST [inference-gateway]                           3.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.1s
│               ╰── HTTP POST [inference-gateway]                   3.1s
├── execute_tool Read call_86bfi90r                                347µs
├── execute_tool Read call_gqxhy15s                                200µs
├── execute_tool Read call_6minl624                                176µs
├── execute_tool Read call_xbeek6j8                                122µs
├── chat ollama_cloud/deepseek-v4-flash                             1.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.9s
│       ╰── HTTP POST [inference-gateway]                           1.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.9s
│               ╰── HTTP POST [inference-gateway]                   1.9s
├── execute_tool Bash call_jhw9exv3                                22.4s [error: tool_error]
├── execute_tool Bash call_32xrwfu5                                717ms [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             3.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.4s
│       ╰── HTTP POST [inference-gateway]                           3.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.4s
│               ╰── HTTP POST [inference-gateway]                   3.4s
├── execute_tool Grep call_tet4ecfy                                  4ms
├── execute_tool Grep call_pkp1zy5b                                 78ms
├── chat ollama_cloud/deepseek-v4-flash                             2.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.1s
│       ╰── HTTP POST [inference-gateway]                           2.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.1s
│               ╰── HTTP POST [inference-gateway]                   2.1s
├── execute_tool Grep call_7ezavjv2                                 77ms
├── execute_tool Read call_v7ha5l4i                                177µs
├── chat ollama_cloud/deepseek-v4-flash                             2.3s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.3s
│       ╰── HTTP POST [inference-gateway]                           2.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.3s
│               ╰── HTTP POST [inference-gateway]                   2.3s
├── execute_tool Read call_sjt0mjt2                                187µs
├── execute_tool Read call_bo6guty6                                249µs
├── chat ollama_cloud/deepseek-v4-flash                             3.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.1s
│       ╰── HTTP POST [inference-gateway]                           3.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.1s
│               ╰── HTTP POST [inference-gateway]                   3.1s
├── execute_tool TodoWrite call_xjtdlb8n                            63µs
├── chat ollama_cloud/deepseek-v4-flash                             3.8s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.8s
│       ╰── HTTP POST [inference-gateway]                           3.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.8s
│               ╰── HTTP POST [inference-gateway]                   3.8s
├── execute_tool Grep call_0n4svxty                                280µs
├── execute_tool Grep call_ezil5ywk                                524µs
├── chat ollama_cloud/deepseek-v4-flash                             2.2s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.2s
│       ╰── HTTP POST [inference-gateway]                           2.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.2s
│               ╰── HTTP POST [inference-gateway]                   2.2s
├── execute_tool Read call_nyknlujb                                164µs
├── chat ollama_cloud/deepseek-v4-flash                             3.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.3s
│       ╰── HTTP POST [inference-gateway]                           3.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.3s
│               ╰── HTTP POST [inference-gateway]                   3.3s
├── execute_tool Edit call_yj1ba6vx                                  1ms
├── chat ollama_cloud/deepseek-v4-flash                             3.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.4s
│       ╰── HTTP POST [inference-gateway]                           3.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.4s
│               ╰── HTTP POST [inference-gateway]                   3.4s
├── execute_tool Bash call_g8x0snsm                                35.1s
├── chat ollama_cloud/deepseek-v4-flash                             2.6s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.6s
│       ╰── HTTP POST [inference-gateway]                           2.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.6s
│               ╰── HTTP POST [inference-gateway]                   2.6s
├── execute_tool TodoWrite call_1wwa2y9f                            60µs
├── chat ollama_cloud/deepseek-v4-flash                             5.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.0s
│       ╰── HTTP POST [inference-gateway]                           5.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.0s
│               ╰── HTTP POST [inference-gateway]                   5.0s
├── execute_tool Bash call_zc7leoso                                 10ms
├── chat ollama_cloud/deepseek-v4-flash                             3.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.0s
│       ╰── HTTP POST [inference-gateway]                           3.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.0s
│               ╰── HTTP POST [inference-gateway]                   3.0s
├── execute_tool Bash call_lmmd569x                                 3.3s
├── chat ollama_cloud/deepseek-v4-flash                             1.8s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.8s
│       ╰── HTTP POST [inference-gateway]                           1.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.8s
│               ╰── HTTP POST [inference-gateway]                   1.8s
├── execute_tool Bash call_ltd8up3p                                 1.3s
├── chat ollama_cloud/deepseek-v4-flash                             2.2s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.2s
│       ╰── HTTP POST [inference-gateway]                           2.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.2s
│               ╰── HTTP POST [inference-gateway]                   2.2s
├── execute_tool Wait call_9mz7qkgr                                429ms [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             1.8s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.7s
│       ╰── HTTP POST [inference-gateway]                           1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.7s
│               ╰── HTTP POST [inference-gateway]                   1.7s
├── execute_tool Bash call_w1gjszoe                                492ms [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             2.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.5s
│       ╰── HTTP POST [inference-gateway]                           2.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.5s
│               ╰── HTTP POST [inference-gateway]                   2.5s
├── execute_tool Wait call_j6a7k027                                7m40s
├── chat ollama_cloud/deepseek-v4-flash                             2.8s
├── execute_tool TodoWrite call_t0rt7u60                            66µs
╰── chat ollama_cloud/deepseek-v4-flash                             3.3s
Stats
Tool Calls

╭───────────┬───────┬───────┬──────────╮
│ Tool      │ Calls │ Fail% │ Avg      │
├───────────┼───────┼───────┼──────────┤
│ Bash      │ 9     │ 33%   │ 7040ms   │
│ Read      │ 8     │ 0%    │ 0ms      │
│ Grep      │ 5     │ 0%    │ 32ms     │
│ TodoWrite │ 4     │ 0%    │ 0ms      │
│ Wait      │ 2     │ 50%   │ 230445ms │
│ Edit      │ 1     │ 0%    │ 1ms      │
╰───────────┴───────┴───────┴──────────╯

Token Usage

╭────────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
│ Model                          │ Prompt  │ Cached │ Completion │ Total   │ Cost │
├────────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
│ ollama_cloud/deepseek-v4-flash │ 1154402 │ 0      │ 4743       │ 1159145 │ -    │
╰────────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ standard │ 1        │
╰───────────┴──────────┴──────────╯
⚠️ 4 log(s)
  • Bash call_32xrwfu5:
    exit status 1: lint	fail	1m2s	https://github.com/inference-gateway/cli/actions/runs/30906779979/job/91983697706	
    vet	fail	1m13s	https://github.com/inference-gateway/cli/actions/runs/30906779979/job/91983697726	
    build	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30906779979/job/91984005349	
    e2e	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30906779979/job/91984006242	
    postgres	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30906779979/job/91984005928	
    test	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30906779979/job/91984005599	
    Analyze (actions)	pass	41s	https://github.com/inference-gateway/cli/actions/runs/30906778012/job/91983596038	
    Analyze (go)	pass	1m48s	https://github.com/inference-gateway/cli/actions/runs/30906778012/job/91983596079	
    Analyze (javascript-typescript)	pass	1m2s	https://github.com/inference-gateway/cli/actions/runs/30906778012/job/91983596107	
    CodeQL	pass	3s	https://github.com/inference-gateway/cli/runs/91983729324	
    prepare	pass	24s	https://github.com/inference-gateway/cli/actions/runs/30906779979/job/91983600024
    
  • Bash call_jhw9exv3:
    exit status 201: �[32mtask: [precommit:run] ./.githooks/pre-commit
    �[0mpre-commit: using task from PATH (/opt/hostedtoolcache/task/3.48.0/x64/bin/task)
    �[32mtask: [mod:tidy] go mod tidy
    �[0m�[32mtask: [fmt] go fmt ./...
    �[0m�[32mtask: [lint] golangci-lint run
    �[0mconfig/agent_defaults.go:1: : # github.com/inference-gateway/cli/config [github.com/inference-gateway/cli/config.test]
    config/config.go:180:18: undefined: MultiEditToolConfig (typecheck)
    package config
    1 issues:
    * typecheck: 1
    ::error title=Task 'lint' failed::exit status 1
    �[31mtask: Failed to run task "lint": exit status 1
    �[0m::error title=Task 'precommit:run' failed::exit status 201
    �[31mtask: Failed to run task "precommit:run": exit status 201
    �[0m
    
  • Wait call_9mz7qkgr:
    check command failed with exit code 1 (not in pending_exit_codes)
    
  • Bash call_w1gjszoe:
    exit status 8: Analyze (actions)	pending	0	https://github.com/inference-gateway/cli/actions/runs/30908010372/job/91987587796	
    Analyze (go)	pending	0	https://github.com/inference-gateway/cli/actions/runs/30908010372/job/91987587670	
    Analyze (javascript-typescript)	pending	0	https://github.com/inference-gateway/cli/actions/runs/30908010372/job/91987587510
    

Triggered by edenreich · Infer Action · OSS

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.
@edenreich

Copy link
Copy Markdown
Contributor

@infer can you update the title and the body of this PR?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Model: ollama_cloud/deepseek-v4-flash · View Job

Todos

Pull Request

#1007

✅ Infer Result: Success

Done. PR #1007 has been updated:

  • Title: fix: resolve #1006 - handle max turns properly and add missing MultiEditToolConfig
  • Body: Now properly describes both changes in the PR:
    1. Agent max-turns handling - dispatches hooks, waits for background tasks, returns a descriptive error, and maps it to stopped_early in telemetry
    2. Missing MultiEditToolConfig struct and approval wiring in config.go

Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 26s

Tokens: 203,058 in · 1,553 out · 204,611 total (8 requests)

Tool calls: 9 total · 100% success rate

Traces
Session: 1785846103-c088afc2

session (standard, success)                                        24.5s
├── chat ollama_cloud/deepseek-v4-flash                             1.8s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.8s
│       ╰── HTTP POST [inference-gateway]                           1.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.8s
│               ╰── HTTP POST [inference-gateway]                   1.8s
├── execute_tool TodoWrite call_t7hfpis2                            78µs
├── chat ollama_cloud/deepseek-v4-flash                             1.3s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.3s
│       ╰── HTTP POST [inference-gateway]                           1.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.3s
│               ╰── HTTP POST [inference-gateway]                   1.3s
├── execute_tool Bash call_mqwlwojd                                  6ms
├── execute_tool Bash call_5663ea0l                                324ms
├── execute_tool Bash call_sslxibse                                  6ms
├── chat ollama_cloud/deepseek-v4-flash                             3.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.0s
│       ╰── HTTP POST [inference-gateway]                           3.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.0s
│               ╰── HTTP POST [inference-gateway]                   3.0s
├── execute_tool TodoWrite call_9czwwx3f                            60µs
├── chat ollama_cloud/deepseek-v4-flash                             8.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               8.1s
│       ╰── HTTP POST [inference-gateway]                           8.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     8.1s
│               ╰── HTTP POST [inference-gateway]                   8.1s
├── execute_tool Write call_dkuzge4x                               928µs
├── chat ollama_cloud/deepseek-v4-flash                             2.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.0s
│       ╰── HTTP POST [inference-gateway]                           2.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.0s
│               ╰── HTTP POST [inference-gateway]                   2.0s
├── execute_tool Bash call_p5r888uc                                 1.5s
├── chat ollama_cloud/deepseek-v4-flash                             1.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.4s
│       ╰── HTTP POST [inference-gateway]                           1.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.4s
│               ╰── HTTP POST [inference-gateway]                   1.4s
├── execute_tool Bash call_aqehsx3f                                310ms
├── chat ollama_cloud/deepseek-v4-flash                             1.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.5s
│       ╰── HTTP POST [inference-gateway]                           1.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.5s
│               ╰── HTTP POST [inference-gateway]                   1.5s
├── execute_tool TodoWrite call_yxefo4bw                            60µs
╰── chat ollama_cloud/deepseek-v4-flash                             2.7s
Stats
Tool Calls

╭───────────┬───────┬───────┬───────╮
│ Tool      │ Calls │ Fail% │ Avg   │
├───────────┼───────┼───────┼───────┤
│ Bash      │ 5     │ 0%    │ 420ms │
│ TodoWrite │ 3     │ 0%    │ 0ms   │
│ Write     │ 1     │ 0%    │ 0ms   │
╰───────────┴───────┴───────┴───────╯

Token Usage

╭────────────────────────────────┬────────┬────────┬────────────┬────────┬──────╮
│ Model                          │ Prompt │ Cached │ Completion │ Total  │ Cost │
├────────────────────────────────┼────────┼────────┼────────────┼────────┼──────┤
│ ollama_cloud/deepseek-v4-flash │ 203058 │ 0      │ 1553       │ 204611 │ -    │
╰────────────────────────────────┴────────┴────────┴────────────┴────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ standard │ 1        │
╰───────────┴──────────┴──────────╯

Triggered by edenreich · Infer Action · OSS

@inference-gateway-maintainer inference-gateway-maintainer Bot changed the title fix: resolve #1006 (salvaged) fix: resolve #1006 - handle max turns properly and add missing MultiEditToolConfig Aug 4, 2026
@edenreich
edenreich marked this pull request as ready for review August 4, 2026 12:24
@edenreich
edenreich requested a review from a team as a code owner August 4, 2026 12:24
@edenreich

edenreich commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@infer Can you address these, use /go /ponytail:ponytail

Verdict: correct direction, but not ready to merge

CI is green and the diff is small, but I found two blocking issues.

1. INFER_TOOLS_MULTI_EDIT_REQUIRE_APPROVAL likely does not work

The new config works in YAML, but probably not through environment variables, which is how infer-action configures headless runs.

MultiEdit is missing from DefaultConfig(), so Viper never registers the key. The fallback env resolver also skips *bool fields.

Fix: add a default MultiEdit config entry, mirroring Edit.

2. False max_turns_reached on successful completion

When the model finishes normally on the final allowed turn, completedTurns >= maxTurns is still true. The session is then incorrectly reported as failed.

Fix: only return max_turns_reached when the loop actually ended through turn exhaustion.

Additional notes

  • Max-turn runs will now exit with code 1. infer-action must handle this.
  • The PR provides an error string, not a structured session marker.
  • No tests cover either new behavior.
  • Prefer a sentinel error with errors.Is instead of matching "max_turns_reached" as a string.
  • MultiEditToolConfig.Enabled appears unused.

Bottom line

Request changes:

  1. Register MultiEdit in DefaultConfig().
  2. Fix the final-turn completion boundary.
  3. Ideally add a sentinel error and focused tests.

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Model: ollama_cloud/deepseek-v4-flash · View Job

Todos

  • Read current diff and understand existing changes
  • Register MultiEdit in DefaultConfig() so env vars work
  • Add sentinel error for max_turns_reached
  • Fix false max_turns_reached on successful completion
  • Add focused tests for the new behavior
  • Run pre-commit checks and push

Pull Request

#1007

✅ Infer Result: Success

All changes are committed and pushed to PR #1007. Here's a summary of what was done:

Changes made

1. Register MultiEdit in DefaultConfig() (config/config.go)

Added a default MultiEditToolConfig entry in DefaultConfig(), mirroring Edit, so Viper registers the key and INFER_TOOLS_MULTI_EDIT_REQUIRE_APPROVAL works through environment variables.

2. Add sentinel error ErrMaxTurnsReached (internal/domain/agent.go)

Defined var ErrMaxTurnsReached = errors.New("max_turns_reached") so callers can use errors.Is instead of fragile string matching.

3. Fix false max_turns_reached on successful completion (cmd/agent.go)

  • Added a completedNormally flag set to true when the loop exits via the "task appears complete" break.
  • The post-loop check is now if !completedNormally && s.completedTurns >= s.maxTurns, so a task that finishes on the final allowed turn is not incorrectly reported as max-turns exhaustion.
  • The error now wraps domain.ErrMaxTurnsReached with %w for proper errors.Is support.

4. Use errors.Is in agentSessionOutcome (cmd/agent.go)

Replaced strings.Contains(err.Error(), "max_turns_reached") with errors.Is(err, domain.ErrMaxTurnsReached).

5. Add focused tests (cmd/agent_test.go)

Added TestAgentSessionOutcome - a table-driven test covering nil (success), context.Canceled (stopped_early), context.DeadlineExceeded (stopped_early), ErrMaxTurnsReached wrapped (stopped_early), and a generic error (failed).

Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 3m 41s

Tokens: 4,693,265 in · 10,780 out · 4,704,045 total (28 requests)

Tool calls: 34 total · 97% success rate

Traces
Session: 1785847464-55ac6d6e

session (standard, success)                                        3m40s
├── chat ollama_cloud/deepseek-v4-flash                             2.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.4s
│       ╰── HTTP POST [inference-gateway]                           2.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.4s
│               ╰── HTTP POST [inference-gateway]                   2.4s
├── execute_tool TodoWrite call_brx2vkoa                            79µs
├── chat ollama_cloud/deepseek-v4-flash                             2.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.1s
│       ╰── HTTP POST [inference-gateway]                           2.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.1s
│               ╰── HTTP POST [inference-gateway]                   2.1s
├── execute_tool Bash call_1iww2qqs                                  5ms
├── execute_tool Bash call_3rbr0fwe                                  6ms
├── chat ollama_cloud/deepseek-v4-flash                             2.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.4s
│       ╰── HTTP POST [inference-gateway]                           2.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.4s
│               ╰── HTTP POST [inference-gateway]                   2.4s
├── execute_tool Read call_f0gjnprj                                189µs
├── execute_tool Read call_p4zu8mdy                                  1ms
├── execute_tool Read call_a1n4dpwh                                922µs
├── execute_tool Read call_53urelv1                                198µs
├── chat ollama_cloud/deepseek-v4-flash                             7.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               7.9s
│       ╰── HTTP POST [inference-gateway]                           7.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     7.9s
│               ╰── HTTP POST [inference-gateway]                   7.9s [error: *errors.errorString]
├── execute_tool TodoWrite call_ie4oy4v6                            63µs
├── chat ollama_cloud/deepseek-v4-flash                             3.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.9s
│       ╰── HTTP POST [inference-gateway]                           3.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.9s
│               ╰── HTTP POST [inference-gateway]                   3.9s
├── execute_tool Read call_09yv4bfz                                219µs
├── execute_tool Grep call_dt3x9vsc                                347ms
├── execute_tool Grep call_3d5bp9lf                                356ms
├── chat ollama_cloud/deepseek-v4-flash                            10.3s
│   ╰── POST /v1/chat/completions [inference-gateway]              10.3s
│       ╰── HTTP POST [inference-gateway]                          10.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway]    10.3s
│               ╰── HTTP POST [inference-gateway]                  10.3s
├── execute_tool Grep call_ub9w62bq                                 16ms
├── execute_tool Read call_29rnykes                                177µs
├── chat ollama_cloud/deepseek-v4-flash                             6.2s
│   ╰── POST /v1/chat/completions [inference-gateway]               6.2s
│       ╰── HTTP POST [inference-gateway]                           6.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     6.2s
│               ╰── HTTP POST [inference-gateway]                   6.2s
├── execute_tool Edit call_tllfy3nz                                971µs
├── chat ollama_cloud/deepseek-v4-flash                             4.3s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.3s
│       ╰── HTTP POST [inference-gateway]                           4.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.3s
│               ╰── HTTP POST [inference-gateway]                   4.3s
├── execute_tool TodoWrite call_nrmujdvz                            63µs
├── chat ollama_cloud/deepseek-v4-flash                             4.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.1s
│       ╰── HTTP POST [inference-gateway]                           4.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.1s
│               ╰── HTTP POST [inference-gateway]                   4.1s
├── execute_tool Edit call_bg4gy5go                                390µs
├── chat ollama_cloud/deepseek-v4-flash                            10.9s
│   ╰── POST /v1/chat/completions [inference-gateway]              10.9s
│       ╰── HTTP POST [inference-gateway]                          10.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]    10.9s
│               ╰── HTTP POST [inference-gateway]                  10.9s
├── chat ollama_cloud/deepseek-v4-flash                             3.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.1s
│       ╰── HTTP POST [inference-gateway]                           3.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.1s
│               ╰── HTTP POST [inference-gateway]                   3.1s
├── execute_tool Edit call_vious43c                                455µs
├── chat ollama_cloud/deepseek-v4-flash                             5.8s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.8s
│       ╰── HTTP POST [inference-gateway]                           5.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.8s
│               ╰── HTTP POST [inference-gateway]                   5.8s
├── execute_tool Edit call_p1bycr3e                                  1ms
├── chat ollama_cloud/deepseek-v4-flash                             6.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               6.4s
│       ╰── HTTP POST [inference-gateway]                           6.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     6.4s
│               ╰── HTTP POST [inference-gateway]                   6.4s
├── execute_tool Grep call_u1lxprre                                486µs
├── chat ollama_cloud/deepseek-v4-flash                             3.7s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.6s
│       ╰── HTTP POST [inference-gateway]                           3.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.6s
│               ╰── HTTP POST [inference-gateway]                   3.6s
├── execute_tool Read call_gsimz8u3                                194µs
├── chat ollama_cloud/deepseek-v4-flash                             4.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.1s
│       ╰── HTTP POST [inference-gateway]                           4.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.1s
│               ╰── HTTP POST [inference-gateway]                   4.1s
├── execute_tool Read call_pfo7q157                                194µs
├── chat ollama_cloud/deepseek-v4-flash                             3.3s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.3s
│       ╰── HTTP POST [inference-gateway]                           3.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.3s
│               ╰── HTTP POST [inference-gateway]                   3.3s
├── execute_tool Read call_dva1dcbb                                177µs
├── chat ollama_cloud/deepseek-v4-flash                             4.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.1s
│       ╰── HTTP POST [inference-gateway]                           4.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.1s
│               ╰── HTTP POST [inference-gateway]                   4.1s
├── execute_tool Edit call_yawgw5op                                  2ms
├── chat ollama_cloud/deepseek-v4-flash                             4.3s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.3s
│       ╰── HTTP POST [inference-gateway]                           4.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.3s
│               ╰── HTTP POST [inference-gateway]                   4.3s
├── execute_tool Grep call_p5t9vz6k                                593µs
├── chat ollama_cloud/deepseek-v4-flash                             4.7s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.7s
│       ╰── HTTP POST [inference-gateway]                           4.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.7s
│               ╰── HTTP POST [inference-gateway]                   4.7s
├── execute_tool Edit call_3h658ryy                                  1ms
├── chat ollama_cloud/deepseek-v4-flash                             7.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               7.5s
│       ╰── HTTP POST [inference-gateway]                           7.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     7.5s
│               ╰── HTTP POST [inference-gateway]                   7.5s
├── execute_tool TodoWrite call_kaq7rczo                            65µs
├── chat ollama_cloud/deepseek-v4-flash                             5.7s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.7s
│       ╰── HTTP POST [inference-gateway]                           5.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.7s
│               ╰── HTTP POST [inference-gateway]                   5.7s
├── execute_tool Bash call_xtusi6so                                51.0s [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             7.2s
│   ╰── POST /v1/chat/completions [inference-gateway]               7.2s
│       ╰── HTTP POST [inference-gateway]                           7.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     7.1s
│               ╰── HTTP POST [inference-gateway]                   7.1s
├── execute_tool Edit call_3ahbydjb                                  1ms
├── chat ollama_cloud/deepseek-v4-flash                             5.2s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.2s
│       ╰── HTTP POST [inference-gateway]                           5.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.2s
│               ╰── HTTP POST [inference-gateway]                   5.2s
├── execute_tool Bash call_vj48mhxr                                10.5s
├── chat ollama_cloud/deepseek-v4-flash                             6.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               6.8s
│       ╰── HTTP POST [inference-gateway]                           6.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     6.8s
│               ╰── HTTP POST [inference-gateway]                   6.8s
├── execute_tool Bash call_dq01x4m0                                 12ms
├── chat ollama_cloud/deepseek-v4-flash                             4.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.5s
│       ╰── HTTP POST [inference-gateway]                           4.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.5s
│               ╰── HTTP POST [inference-gateway]                   4.5s
├── execute_tool Bash call_5cowvm4h                                 3.4s
├── chat ollama_cloud/deepseek-v4-flash                            12.1s
│   ╰── POST /v1/chat/completions [inference-gateway]              12.1s
│       ╰── HTTP POST [inference-gateway]                          12.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]    12.1s
│               ╰── HTTP POST [inference-gateway]                  12.1s
├── execute_tool Bash call_w4belusg                                 1.5s
├── chat ollama_cloud/deepseek-v4-flash                             4.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.0s
│       ╰── HTTP POST [inference-gateway]                           3.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.9s
│               ╰── HTTP POST [inference-gateway]                   3.9s
├── execute_tool TodoWrite call_460q7now                            75µs
╰── chat ollama_cloud/deepseek-v4-flash                             4.4s
Stats
Tool Calls

╭───────────┬───────┬───────┬────────╮
│ Tool      │ Calls │ Fail% │ Avg    │
├───────────┼───────┼───────┼────────┤
│ Read      │ 9     │ 0%    │ 0ms    │
│ Bash      │ 7     │ 14%   │ 9490ms │
│ Edit      │ 7     │ 0%    │ 1ms    │
│ TodoWrite │ 5     │ 0%    │ 0ms    │
│ Grep      │ 5     │ 0%    │ 144ms  │
╰───────────┴───────┴───────┴────────╯

Token Usage

╭────────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
│ Model                          │ Prompt  │ Cached │ Completion │ Total   │ Cost │
├────────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
│ ollama_cloud/deepseek-v4-flash │ 4693265 │ 0      │ 10780      │ 4704045 │ -    │
╰────────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ standard │ 1        │
╰───────────┴──────────┴──────────╯
⚠️ 1 log(s)
  • Bash call_xtusi6so:
    exit status 201: �[32mtask: [precommit:run] ./.githooks/pre-commit
    �[0mpre-commit: using task from PATH (/opt/hostedtoolcache/task/3.48.0/x64/bin/task)
    �[32mtask: [mod:tidy] go mod tidy
    �[0m�[32mtask: [fmt] go fmt ./...
    �[0m�[32mtask: [lint] golangci-lint run
    �[0mcmd/agent.go:1: : # github.com/inference-gateway/cli/cmd [github.com/inference-gateway/cli/cmd.test]
    cmd/agent_test.go:101:55: undefined: telemetry
    cmd/agent_test.go:102:81: undefined: telemetry
    cmd/agent_test.go:103:90: undefined: telemetry
    cmd/agent_test.go:104:134: undefined: telemetry
    cmd/agent_test.go:105:89: undefined: telemetry (typecheck)
    package cmd
    1 issues:
    * typecheck: 1
    ::error title=Task 'lint' failed::exit status 1
    �[31mtask: Failed to run task "lint": exit status 1
    �[0m::error title=Task 'precommit:run' failed::exit status 201
    �[31mtask: Failed to run task "precommit:run": exit status 201
    �[0m
    

Triggered by edenreich · Infer Action · OSS

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.
@edenreich edenreich changed the title fix: resolve #1006 - handle max turns properly and add missing MultiEditToolConfig fix: Handle max turns properly and add missing MultiEditToolConfig Aug 4, 2026
@edenreich edenreich changed the title fix: Handle max turns properly and add missing MultiEditToolConfig fix: handle max turns properly and add missing MultiEditToolConfig Aug 4, 2026
@edenreich

Copy link
Copy Markdown
Contributor

@infer Can you fix these nit-picking:

  • cmd/agent.go:L554-556: shrink: duplicated dispatchHooks(HookPostSession) + waitForBackgroundTasks pair - the identical pair sits 3 lines below. Set the error, fall through to the shared block, return it. -4 lines.
  • config/config.go:L245: yagni: MultiEditToolConfig.Enabled still never read - enablement comes from cfg.Tools.Edit.Enabled (internal/agent/tools/multiedit.go:29,40), so tools.multi_edit.enabled: false silently does nothing. Harmless dead flexibility; wire it or drop it in a follow-up.

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Model: ollama_cloud/deepseek-v4-flash · View Job

Todos

  • Read cmd/agent.go around L554-556 to understand the duplicated dispatchHooks/waitForBackgroundTasks pattern
  • Fix duplicated dispatchHooks + waitForBackgroundTasks in cmd/agent.go
  • Read config/config.go around L245 and internal/agent/tools/multiedit.go to understand MultiEditToolConfig.Enabled usage
  • Remove unused MultiEditToolConfig.Enabled field
  • Run precommit checks and push

Pull Request

#1007

✅ Infer Result: Success

Both nit-picking issues are fixed and pushed to PR #1007. Here's what changed:

1. cmd/agent.go - Deduplicated dispatchHooks + waitForBackgroundTasks (-4 lines)

The max-turns block no longer duplicates the dispatchHooks(HookPostSession) + waitForBackgroundTasks pair. Instead, it sets a sessionErr variable and falls through to the shared post-session block, which runs hooks and waits for background tasks exactly once. The error is returned after the shared block.

2. config/config.go - Removed unused MultiEditToolConfig.Enabled

The Enabled field was dead code - multiedit.go uses cfg.Tools.Edit.Enabled for enablement, so tools.multi_edit.enabled: false silently did nothing. Removed the field from the struct and from DefaultConfig(). The RequireApproval field (which IS read by IsApprovalRequired) remains.

Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 2m 6s

Tokens: 1,378,636 in · 5,851 out · 1,384,487 total (17 requests)

Tool calls: 21 total · 100% success rate

Traces
Session: 1785850822-9ccb777f

session (standard, success)                                         2m4s
├── chat ollama_cloud/deepseek-v4-flash                             3.8s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.8s
│       ╰── HTTP POST [inference-gateway]                           3.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.8s
│               ╰── HTTP POST [inference-gateway]                   3.8s
├── execute_tool TodoWrite call_ucprwlxf                            90µs
├── chat ollama_cloud/deepseek-v4-flash                             2.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.1s
│       ╰── HTTP POST [inference-gateway]                           2.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.1s
│               ╰── HTTP POST [inference-gateway]                   2.1s
├── execute_tool Read call_1yz4pigj                                171µs
├── execute_tool Read call_rkuame6t                                190µs
├── execute_tool Read call_zowned19                                121µs
├── chat ollama_cloud/deepseek-v4-flash                             8.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               8.4s
│       ╰── HTTP POST [inference-gateway]                           8.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     8.4s
│               ╰── HTTP POST [inference-gateway]                   8.4s
├── execute_tool Read call_vrgx9pfo                                212µs
├── execute_tool Grep call_37m1yybd                                 99ms
├── execute_tool Grep call_hv4gk7oh                                 98ms
├── chat ollama_cloud/deepseek-v4-flash                             4.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.4s
│       ╰── HTTP POST [inference-gateway]                           4.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.4s
│               ╰── HTTP POST [inference-gateway]                   4.4s
├── execute_tool Grep call_g6p08qs4                                  5ms
├── execute_tool Read call_u1hqh868                                199µs
├── chat ollama_cloud/deepseek-v4-flash                             2.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.1s
│       ╰── HTTP POST [inference-gateway]                           2.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.1s
│               ╰── HTTP POST [inference-gateway]                   2.1s
├── execute_tool Read call_4oufx657                                211µs
├── chat ollama_cloud/deepseek-v4-flash                             3.7s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.7s
│       ╰── HTTP POST [inference-gateway]                           3.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.6s
│               ╰── HTTP POST [inference-gateway]                   3.6s
├── execute_tool TodoWrite call_dj0iq8gc                            68µs
├── chat ollama_cloud/deepseek-v4-flash                             3.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.9s
│       ╰── HTTP POST [inference-gateway]                           3.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.9s
│               ╰── HTTP POST [inference-gateway]                   3.9s
├── execute_tool Edit call_gi3vgzx5                                  3ms
├── chat ollama_cloud/deepseek-v4-flash                             2.7s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.7s
│       ╰── HTTP POST [inference-gateway]                           2.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.7s
│               ╰── HTTP POST [inference-gateway]                   2.7s
├── execute_tool TodoWrite call_hjtr4awz                            55µs
├── chat ollama_cloud/deepseek-v4-flash                             2.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.5s
│       ╰── HTTP POST [inference-gateway]                           2.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.5s
│               ╰── HTTP POST [inference-gateway]                   2.5s
├── execute_tool Edit call_2az68svt                                  1ms
├── chat ollama_cloud/deepseek-v4-flash                             5.6s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.6s
│       ╰── HTTP POST [inference-gateway]                           5.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.6s
│               ╰── HTTP POST [inference-gateway]                   5.6s
├── execute_tool Edit call_xlwc7sdp                                983µs
├── chat ollama_cloud/deepseek-v4-flash                             3.6s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.6s
│       ╰── HTTP POST [inference-gateway]                           3.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.6s
│               ╰── HTTP POST [inference-gateway]                   3.6s
├── execute_tool TodoWrite call_wc8rltjf                            82µs
├── chat ollama_cloud/deepseek-v4-flash                             5.6s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.5s
│       ╰── HTTP POST [inference-gateway]                           5.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.5s
│               ╰── HTTP POST [inference-gateway]                   5.5s
├── execute_tool Bash call_04q7sbm7                                54.2s
├── chat ollama_cloud/deepseek-v4-flash                             2.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.1s
│       ╰── HTTP POST [inference-gateway]                           2.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.1s
│               ╰── HTTP POST [inference-gateway]                   2.1s
├── execute_tool Bash call_fi1ir40l                                 12ms
├── chat ollama_cloud/deepseek-v4-flash                             4.6s
│   ╰── POST /v1/chat/completions [inference-gateway]               4.6s
│       ╰── HTTP POST [inference-gateway]                           4.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     4.6s
│               ╰── HTTP POST [inference-gateway]                   4.6s
├── execute_tool Bash call_1g5h60p3                                 3.3s
├── chat ollama_cloud/deepseek-v4-flash                             2.6s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.6s
│       ╰── HTTP POST [inference-gateway]                           2.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.6s
│               ╰── HTTP POST [inference-gateway]                   2.6s
├── execute_tool Bash call_h4ymtfud                                 1.5s
├── chat ollama_cloud/deepseek-v4-flash                             3.3s
├── execute_tool TodoWrite call_qam0736d                            52µs
╰── chat ollama_cloud/deepseek-v4-flash                             3.0s
Stats
Tool Calls

╭───────────┬───────┬───────┬─────────╮
│ Tool      │ Calls │ Fail% │ Avg     │
├───────────┼───────┼───────┼─────────┤
│ Read      │ 6     │ 0%    │ 0ms     │
│ TodoWrite │ 5     │ 0%    │ 0ms     │
│ Bash      │ 4     │ 0%    │ 14750ms │
│ Grep      │ 3     │ 0%    │ 67ms    │
│ Edit      │ 3     │ 0%    │ 1ms     │
╰───────────┴───────┴───────┴─────────╯

Token Usage

╭────────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
│ Model                          │ Prompt  │ Cached │ Completion │ Total   │ Cost │
├────────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
│ ollama_cloud/deepseek-v4-flash │ 1378636 │ 0      │ 5851       │ 1384487 │ -    │
╰────────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ standard │ 1        │
╰───────────┴──────────┴──────────╯

Triggered by edenreich · Infer Action · OSS

inference-gateway-maintainer Bot and others added 2 commits August 4, 2026 13:42
…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.
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.160.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] max-turns exhaustion exits 0 mid-task; salvage pushes a non-descriptive PR

1 participant