Skip to content

feat: add wrap-up reminders for agent mode (#628) - #635

Merged
edenreich merged 8 commits into
mainfrom
fix/issue-628
Jun 18, 2026
Merged

edenreich merged 8 commits into
mainfrom
fix/issue-628

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #628

@edenreich

Copy link
Copy Markdown
Contributor

@infer Please update the description and the title of this PR. Also can you fix the CI?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor Author

View Job

Todos

  • Understand current branch state and CI status
  • Fix CI - formatting issue in config/prompts.go
  • Update PR title and description

Pull Request

#635

✅ Infer Result: Success

The task is complete. ✅

No further action needed.

Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 9m 42s

Tokens: 5,595,628 in · 12,613 out · 5,608,241 total (69 requests)

Tool calls: 60 total · 98% success rate

⚠️ 1 failed tool call(s)
  • Edit: file /home/runner/work/cli/cli/config/prompts.go was modified since you last read it (snapshot 2026-06-17T23:17:10Z, now 2026-06-17T23:18:18Z). Use the Read tool to read it again before editing.

Triggered by edenreich · Infer Action

@inference-gateway-maintainer inference-gateway-maintainer Bot changed the title fix: resolve #628 feat: add wrap-up reminders for agent mode (#628) Jun 17, 2026
@edenreich
edenreich marked this pull request as ready for review June 17, 2026 23:22
@edenreich
edenreich requested a review from a team as a code owner June 17, 2026 23:22
@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor Author

Updated PR title and description per request.

Comment thread cmd/agent.go Resolved
Comment thread internal/agent/agent_utils.go Resolved
@edenreich

Copy link
Copy Markdown
Contributor

@claude Can you review this Pull Request? is it ready for merge?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 3m 25s —— View job


PR Review: Wrap-up reminders for agent mode (#628)

Verdict: Mergeable. ✅ CI is green, the maintainer's inline comments are already addressed, and the feature is opt-in and safe by default. There are a few minor (non-blocking) polish items noted below worth considering now or as a follow-up.

What this PR does

Adds an optional "wrap-up" reminder: when an agent session approaches max_turns, the regular periodic reminder_text is swapped for a wrap_up_text so the model can commit/finalize before hitting the ceiling. Wired into both reminder paths (headless cmd/agent.go and streaming internal/agent/agent_utils.go), plus config struct, env overrides, defaults merge, docs, and tests.

Strengths

  • Safe defaults: wrap_up_text defaults to "" and wrap_up_threshold to 0, so the feature is fully disabled unless explicitly configured (config/prompts.go). No behavior change for existing users.
  • Both runtime paths covered: the logic is mirrored in the sync headless loop and the streaming service, matching the existing pattern documented at cmd/agent.go:988.
  • Observability: the phase (periodic / wrap_up) tag is added to both the structured log and the system_reminder stream event - good for downstream observers.
  • Solid tests for the AgentServiceImpl path: within-threshold, before-threshold, empty-text fallback, and the boundary case (agent_reminder_emission_test.go).
  • Maintainer feedback addressed: the empty suggestion blocks all targeted redundant explanatory comments; commit d54478c already removed them. ✔

Findings (minor / non-blocking)

1. Wrap-up reminder is gated behind the interval - can silently never fire. medium
In both paths the wrap-up text is only selected after the interval gate (turn % interval == 0) passes. So the wrap-up reminder only fires on turns that are multiples of interval. If wrap_up_threshold < interval, no turn in the wrap-up window may be a multiple of interval, and the reminder never appears - with no warning.

  • Example: interval: 4 (default), wrap_up_threshold: 1, max_turns: 50 → window is turns 49-50, no multiple of 4 → wrap-up never injected.

Suggest either documenting that wrap_up_threshold should be >= interval, validating it, or decoupling wrap-up injection from the interval gate. Fix this →

2. The wrap-up predicate is duplicated 3x (and computed twice in one call path). low
The condition maxTurns > 0 && WrapUpText != "" && WrapUpThreshold > 0 && (maxTurns-turns) <= WrapUpThreshold appears in cmd/agent.go:1007, agent_utils.go:751 (to pick the text) and again at agent_utils.go:802 (to compute the phase label). In agent_utils.go it is recomputed within the same call, so the phase label and the selected text can drift if one copy is edited. Extracting a single isWithinWrapUpThreshold(turns) helper would keep them in sync. Fix this →

3. The cmd/agent.go wrap-up branch has no test coverage. low
All 94 lines of new tests exercise AgentServiceImpl (internal/agent/). The mirrored wrap-up logic in AgentSession.injectSystemReminderIfDue (cmd/agent.go:993) is not covered - the existing cmd/agent_test.go reminder tests don't set the WrapUp* fields. Given the logic is duplicated, a small test there would guard against the two paths diverging.

Nitpick

  • docs/configuration-reference.md documents the key as agent.system_reminders.text while the actual field is reminder_text - pre-existing, but worth fixing while this section is being touched.

Checklist

  • Read the full diff against origin/main
  • Review changed source files (agent_utils.go, cmd/agent.go, config/prompts.go)
  • Review the new test file
  • Check the maintainer's inline review comments (all addressed by d54478c)
  • Assess CI status (2/2 passing ✅)
  • Provide review verdict

Bottom line: This is ready to merge as-is for the default (disabled) configuration. Finding #1 is the only one I'd recommend addressing before relying on the feature in production, since a misconfigured wrap_up_threshold fails silently - but it can also be a fast follow-up.

--- · branch fix/issue-628

@edenreich

Copy link
Copy Markdown
Contributor

@infer Can you address these nit-picking?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor Author

View Job

Todos

  • Understand current branch state and Claude's review findings
  • Fix Finding #1: Wrap-up reminder gated behind interval - can silently never fire + Finding #2: Extract helper method
  • Fix Finding #3: Add test coverage for cmd/agent.go wrap-up branch
  • Fix nitpick: docs/configuration-reference.md mentions 'text' instead of 'reminder_text'
  • Verify tests pass
  • Commit and push changes

Pull Request

#635

✅ Infer Result: Success

All the nit-picking findings from Claude's review have been fully addressed:

  1. Finding #1 ✅ — Wrap-up reminder decoupled from interval gate; fires regardless of interval when within wrap_up_threshold
  2. Finding #2 ✅ — isWithinWrapUpThreshold helper extracted and shared across all three call sites
  3. Finding #3 ✅ — 5 new sub-tests covering the cmd/agent.go wrap-up path
  4. Docs nitpick ✅ — agent.system_reminders.text → agent.system_reminders.reminder_text

Task complete. The changes are committed and pushed to fix/issue-628 (commit 2c18d3b).

Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 15m 38s

Tokens: 9,384,381 in · 36,317 out · 9,420,698 total (81 requests)

Tool calls: 93 total · 100% success rate

Triggered by edenreich · Infer Action

Comment thread cmd/agent_test.go Resolved
Comment thread cmd/agent_test.go Resolved
Comment thread cmd/agent_test.go Resolved
Comment thread cmd/agent_test.go Resolved
Comment thread cmd/agent_test.go Resolved
Comment thread cmd/agent_test.go Resolved
Comment thread internal/agent/agent_utils.go Resolved
Comment thread cmd/agent.go Resolved
@edenreich

Copy link
Copy Markdown
Contributor

@claude Deepseek fixed the nit-picking, is it ready for merge now?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 14m 27s —— View job


Re-review: are the nit-picks fixed and is it mergeable?


✅ Yes - ready to merge now.

The four review findings are all correctly fixed, and CI - which was actually red, not green - is now passing after I pushed a fix (d2a8c0a).

Verification of the review findings

# Finding Status Where
1 Wrap-up gated behind interval (could silently never fire) ✅ Fixed shouldInjectSystemReminder returns early on isWithinWrapUpThreshold before the turns%interval gate (agent_utils.go:743); headless path applies the interval gate only if !isWrapUp (cmd/agent.go:1009). The test wrap-up fires when wrap_up_threshold < interval covers the exact silent-miss case from my original example.
2 Predicate duplicated 3x / could drift ✅ Fixed isWithinWrapUpThreshold(turns) extracted (agent_utils.go:732) and reused by shouldInjectSystemReminder, getSystemReminderMessage, and injectSystemReminderIfDue, so text selection and the phase label can't diverge.
3 cmd/agent.go wrap-up branch untested ✅ Fixed 5 wrap-up sub-tests now exercise AgentSession.injectSystemReminderIfDue directly.
4 Docs nit (text vs reminder_text) ✅ Fixed docs/configuration-reference.md:332.

CI was failing - now fixed and confirmed green

The PR #635 workflow was green, but the CI workflow was red. The failing step was mislabeled "Install golangci-lint"; it was a real lint error from Finding #3's new test:

cmd/agent_test.go:1153:1: cognitive complexity 51 of func `TestInjectSystemReminderIfDue` is high (> 45) (gocognit)

Per CLAUDE.md, gocognit is capped at 45. Rather than suppress it with //nolint, I split the test along its natural seam - the 5 wrap-up cases moved into a new TestInjectSystemReminderIfDueWrapUp, leaving the periodic cases in TestInjectSystemReminderIfDue.

Re-run on d2a8c0a - all green ✅

✓ prepare   17s
✓ vet     1m04s
✓ lint    1m09s   ← previously failing, now passes
✓ build   1m08s
✓ test    1m21s

Locally verified too: gocognit now 27 and 24 (was 51), go test ./cmd/ passes all 9 sub-tests, go vet and gofmt clean.

Optional, non-blocking (pre-existing - not from this PR)

docs/configuration-reference.md:330-331 lists enabled default true and interval default 10, but the code defaults are false / 4 (config/prompts.go:321). Worth a tiny follow-up but unrelated to this change.

Verdict

Ready to merge. Findings resolved, feature is opt-in/disabled by default, both runtime paths covered, and CI is green on the latest commit.

· branch fix/issue-628

@edenreich

Copy link
Copy Markdown
Contributor

@infer Please fix the ci

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor Author

View Job

Todos

  • Pull latest branch state and understand the current diff vs origin/main
  • Verify all 4 review findings
  • Fix CI: gocognit cognitive complexity > 45 in TestInjectSystemReminderIfDue
  • Verify tests pass
  • [~] Commit and push changes
  • Final merge verdict

Pull Request

#635

⚠️ Infer Result: Stopped early

The agent hit the job's time limit before finishing, so it was stopped to salvage its work. Its committed changes were pushed; the draft pull request is linked above.

Let me try using the gh CLI's git credential helper to push:

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

Tokens: 10,139,317 in · 28,400 out · 10,167,717 total (95 requests)

Tool calls: 105 total · 96% success rate

⚠️ 4 failed tool call(s)
  • Edit: old_string not found in file /home/runner/work/cli/cli/cmd/agent_test.go

No similar content found. Please verify the content exists and matches exactly (including whitespace).

  • Edit: old_string not found in file /home/runner/work/cli/cli/cmd/agent_test.go

No similar content found. Please verify the content exists and matches exactly (including whitespace).

  • Edit: old_string not found in file /home/runner/work/cli/cli/cmd/agent_test.go

Possible matches found:

Near line 1254:
func TestInjectSystemReminderIfDue_WrapUpReminders(t *testing.T) {
\tnewWrapUpSession := func(enabled bool, interval int, reminderText, wrapUpText string, wrapUpThreshold int, maxTurns int) *AgentSession {

Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.

  • Read: access to path '/home/runner/work/cli/cli/.git/config' is excluded for security

Triggered by edenreich · Infer Action

@edenreich
edenreich merged commit f5d95a5 into main Jun 18, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-628 branch June 18, 2026 00:44
inference-gateway-releaser Bot pushed a commit that referenced this pull request Jun 20, 2026
## [0.122.0](v0.121.1...v0.122.0) (2026-06-20)

### 🚀 Features

* **shortcuts:** add /release-notes shortcut to display changelog entries ([#634](#634)) ([4d0d0bf](4d0d0bf)), closes [#518](#518)
* **explorer:** add snippet selection and annotation for targeted refactoring ([#637](#637)) ([7e619f9](7e619f9)), closes [#599](#599)
* add wrap-up reminders for agent mode ([#628](#628)) ([#635](#635)) ([f5d95a5](f5d95a5))
* **skills:** scan .agents/skills as a third skill location ([#640](#640)) ([6e422b9](6e422b9)), closes [#639](#639) [#639](#639)

### ♻️ Code Refactoring

* **pricing:** add MiniMax models and update subscription terminology ([8df84e7](8df84e7))

### 🔧 Build System

* **deps:** bump alpine from 3.24.0 to 3.24.1 in the docker group ([#630](#630)) ([4d2160e](4d2160e))
* **deps:** bump inference-gateway/.github/.github/workflows/infer.yml from 0.8.0 to 0.10.3 in the github-actions group across 1 directory ([#633](#633)) ([913304d](913304d))
* **deps:** bump the gomod group with 4 updates ([#629](#629)) ([b73f4d3](b73f4d3))

### 👷 CI/CD

* **infer:** centralize infer.yml + sync .infer config ([#638](#638)) ([86d0c18](86d0c18))
* **deps:** upgrade actions/checkout from v6.0.3 to v7.0.0 across workflows ([7befc6c](7befc6c))

### 🧹 Maintenance

* **deps:** bump claude-code 2.1.161 -> 2.1.170, claude-code-action v1.0.135 -> v1.0.142 ([#626](#626)) ([9edfb85](9edfb85))
* **deps:** bump claude-code 2.1.170 -> 2.1.177, claude-code-action v1.0.142 -> v1.0.150 ([#632](#632)) ([c81923f](c81923f))
* **deps:** bump claude-code-action v1.0.150 -> v1.0.152 ([#636](#636)) ([1d58889](1d58889))
* **deps:** bump infer CLI v0.121.0 -> v0.121.1, infer-action v0.12.1 -> v0.13.1 ([#627](#627)) ([c231a03](c231a03))
* bump schema version to 1.13.0 and update docker version to 29.5.2 ([287b1bb](287b1bb))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.122.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Near-max-turns wrap-up system reminder

1 participant