Repository navigation
Description
Summary
The periodic system reminder (prompts.agent.system_reminders) fires on a fixed
interval (turns % interval == 0, in shouldInjectSystemReminder) with no
awareness of max_turns. There is only one reminder_text, reused for every
injection, and the agent loop simply exits when completed_turns >= max_turns
without emitting any "approaching the limit" message or stream event.
That leaves no way to give the agent a fresh, well-timed nudge to stop starting
new work, commit and push everything, and make sure a draft PR exists as the turn
budget runs out. inference-gateway/infer-action depends on this for graceful stop
(its "graceful agent stop" work, infer-action #88): today it can only bake that
guidance into the always-on system prompt, which is far back in context by the time
turns actually run low. infer-action has just slimmed its periodic reminders to
focused per-context nudges and is deferring the timed wrap-up nudge to this feature.
Proposed design
Add two fields to PromptsAgentRemindersConfig (config/prompts.go):
wrap_up_text(string) - reminder injected near the turn limit.wrap_up_threshold(int) - turns-remaining window; inject when
max_turns - turns <= wrap_up_threshold.
In the injection path (shouldInjectSystemReminder / internal/agent/agent_utils.go):
when max_turns > 0 && wrap_up_text != "" && (max_turns - turns) <= wrap_up_threshold,
inject wrap_up_text instead of the regular reminder_text. Outside that window,
behaviour is unchanged.
Surface via env, matching the existing namespace:
INFER_PROMPTS_AGENT_SYSTEM_REMINDERS_WRAP_UP_TEXT and
INFER_PROMPTS_AGENT_SYSTEM_REMINDERS_WRAP_UP_THRESHOLD.
Optionally tag the emitted system_reminder stream event (e.g. add a
phase: "wrap_up" field) so external observers can distinguish a wrap-up nudge from
a periodic one.
Downstream (separate infer-action PR, after a CLI release + pinned-version bump)
Add a buildWrapUpReminder(ctx) plus wrapup-*.md prompt sources and set the new
env vars in runner.ts / action.yml, plus a consumer-overridable input.
Acceptance Criteria
-
PromptsAgentRemindersConfiggainswrap_up_textandwrap_up_threshold
(yaml + mapstructure + env via the existingINFER_PROMPTS_...namespace). - With a low
max_turns,wrap_up_textis injected on the first interval tick
within the finalwrap_up_thresholdturns;reminder_textis used before that. - When
wrap_up_textis empty, behaviour is unchanged (onlyreminder_text). - Unit test covers the threshold boundary (text switches at the expected turn).
- Config/docs reference updated for the two new fields.
Tracked alongside the reminder-slimming change in inference-gateway/infer-action
(fix(prompts): slim periodic reminders to context essentials); that PR will link
back to this issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
edenreich commentedon Jun 17, 2026
@infer Can you work on this?
inference-gateway-maintainer commentedon Jun 17, 2026
View Job
Todos
Pull Request
#635
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.
Now let me run the tests:
Model:
ollama_cloud/deepseek-v4-flash· Exit Code:0· Duration: —Tokens: 15,520,513 in · 31,027 out · 15,551,540 total (96 requests)
Tool calls: 104 total · 94% success rate
Possible matches found:
Near line 743:
// getSystemReminderMessage returns the system reminder message to inject
func (s *AgentServiceImpl) getSystemReminderMessage() sdk.Message {
reminderText := s.config.Prompts.Agent.SystemReminders.ReminderText
if reminderText == "" {
reminderText =
<system-reminder> This is a reminder that your todo list is currently empty. DO NOT mention this to the user explicitly because they are already aware. If you are working on tasks that would benefit from a todo list please use the TodoWrite tool to create one. If not, please feel free to ignore. Again do not mention this message to the user. </system-reminder>}
}
Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.
Possible matches found:
Near line 743:
// getSystemReminderMessage returns the system reminder message to inject
func (s *AgentServiceImpl) getSystemReminderMessage() sdk.Message {
reminderText := s.config.Prompts.Agent.SystemReminders.ReminderText
if reminderText == "" {
reminderText =
<system-reminder> This is a reminder that your todo list is currently empty. DO NOT mention this to the user explicitly because they are already aware. If you are working on tasks that would benefit from a todo list please use the TodoWrite tool to create one. If not, please feel free to ignore. Again do not mention this message to the user. </system-reminder>}
}
Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.
Possible matches found:
Near line 743:
// getSystemReminderMessage returns the system reminder message to inject
func (s *AgentServiceImpl) getSystemReminderMessage() sdk.Message {
reminderText := s.config.Prompts.Agent.SystemReminders.ReminderText
if reminderText == "" {
reminderText =
<system-reminder> This is a reminder that your todo list is currently empty. DO NOT mention this to the user explicitly because they are already aware. If you are working on tasks that would benefit from a todo list please use the TodoWrite tool to create one. If not, please feel free to ignore. Again do not mention this message to the user. </system-reminder>}
}
Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.
Possible matches found:
Near line 743:
// getSystemReminderMessage returns the system reminder message to inject
func (s *AgentServiceImpl) getSystemReminderMessage() sdk.Message {
reminderText := s.config.Prompts.Agent.SystemReminders.ReminderText
if reminderText == "" {
reminderText =
<system-reminder> This is a reminder that your todo list is currently empty. DO NOT mention this to the user explicitly because they are already aware. If you are working on tasks that would benefit from a todo list please use the TodoWrite tool to create one. If not, please feel free to ignore. Again do not mention this message to the user. </system-reminder>}
}
Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.
Possible matches found:
Near line 132:
func TestInjectSystemReminderIfDue_WrapUpTextUsedWithinThreshold(t *testing.T) {
// maxTurns=10, wrapUpThreshold=3, interval=2
// At turn 8: maxTurns(10) - turns(8) = 2 <= threshold(3) => wrap-up text
cfg := remindersWithWrapUpConfig(true, 2, "regular reminder", "wrap up now!", 3, 10)
svc := &AgentServiceImpl{config: cfg}
buf := withDebugStreamWriter(t)
conv := []sdk.Message{}
injected := svc.injectSystemReminderIfDue(8, &conv)
assert.True(t, injected, "interval 2 with turn 8 must fire")
require.Len(t, conv, 1, "reminder must be appended to conversation")
content, _ := conv[0].Content.AsMessageContent0()
assert.Equal(t, "wrap up now!", content, "wrap-up text must be used within threshold")
var event map[string]any
require.NoError(t, json.Unmarshal(bytes.TrimSpace(buf.Bytes()), &event))
assert.Equal(t, "wrap_up", event["phase"], "stream event must indicate wrap_up phase")
}
func TestInjectSystemReminderIfDue_RegularTextUsedBeforeThreshold(t *testing.T) {
// maxTurns=10, wrapUpThreshold=3, interval=2
// At turn 4: maxTurns(10) - turns(4) = 6 > threshold(3) => regular reminder
cfg := remindersWithWrapUpConfig(true, 2, "regular reminder", "wrap up now!", 3, 10)
svc := &AgentServiceImpl{config: cfg}
buf := withDebugStreamWriter(t)
conv := []sdk.Message{}
injected := svc.injectSystemReminderIfDue(4, &conv)
assert.True(t, injected, "interval 2 with turn 4 must fire")
require.Len(t, conv, 1, "reminder must be appended to conversation")
content, _ := conv[0].Content.AsMessageContent0()
assert.Equal(t, "regular reminder", content, "regular reminder text must be used before threshold")
var event map[string]any
require.NoError(t, json.Unmarshal(bytes.TrimSpace(buf.Bytes()), &event))
assert.Equal(t, "periodic", event["phase"], "stream event must indicate periodic phase")
}
func TestInjectSystemReminderIfDue_WrapUpTextEmptyFallsBackToRegular(t *testing.T) {
// When wrap_up_text is empty, behaviour is unchanged (regular reminder used)
cfg := remindersWithWrapUpConfig(true, 2, "regular reminder", "", 3, 10)
svc := &AgentServiceImpl{config: cfg}
buf := withDebugStreamWriter(t)
conv := []sdk.Message{}
injected := svc.injectSystemReminderIfDue(8, &conv)
assert.True(t, injected, "interval 2 with turn 8 must fire")
require.Len(t, conv, 1, "reminder must be appended to conversation")
content, _ := conv[0].Content.AsMessageContent0()
assert.Equal(t, "regular reminder", content, "regular reminder text must be used when wrap_up_text is empty")
var event map[string]any
require.NoError(t, json.Unmarshal(bytes.TrimSpace(buf.Bytes()), &event))
assert.Equal(t, "periodic", event["phase"], "stream event must indicate periodic phase when wrap_up_text is empty")
}
func TestInjectSystemReminderIfDue_WrapUpThresholdBoundary(t *testing.T) {
// maxTurns=10, wrapUpThreshold=3, interval=2
// At turn 6: maxTurns(10) - turns(6) = 4 > threshold(3) => regular reminder
// At turn 8: maxTurns(10) - turns(8) = 2 <= threshold(3) => wrap-up text
cfg := remindersWithWrapUpConfig(true, 2, "regular reminder", "wrap up now!", 3, 10)
svc := &AgentServiceImpl{config: cfg}
// Turn 6: outside threshold (10-6=4 > 3)
conv := []sdk.Message{}
injected := svc.injectSystemReminderIfDue(6, &conv)
assert.True(t, injected)
content, _ := conv[0].Content.AsMessageContent0()
assert.Equal(t, "regular reminder", content, "turn 6 is outside threshold, must use regular text")
// Turn 8: inside threshold (10-8=2 <= 3)
conv2 := []sdk.Message{}
injected2 := svc.injectSystemReminderIfDue(8, &conv2)
assert.True(t, injected2)
content2, _ := conv2[0].Content.AsMessageContent0()
assert.Equal(t, "wrap up now!", content2, "turn 8 is inside threshold, must use wrap-up text")
}
Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.
Possible matches found:
Near line 132:
func TestInjectSystemReminderIfDue_WrapUpTextUsedWithinThreshold(t *testing.T) {
// maxTurns=10, wrapUpThreshold=3, interval=2
// At turn 8: maxTurns(10) - turns(8) = 2 <= threshold(3) => wrap-up text
cfg := remindersWithWrapUpConfig(true, 2, "regular reminder", "wrap up now!", 3, 10)
svc := &AgentServiceImpl{config: cfg}
Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.
Triggered by edenreich · Infer Action
edenreich commentedon Jun 17, 2026
@infer Can you finalise the work? Please update the existing pull request title and description and continue your work there.
inference-gateway-maintainer commentedon Jun 17, 2026
View Job
Todos
Pull Request
#635
✅ Infer Result: Success
The task is complete. All acceptance criteria from the issue have been met:
wrap_up_textandwrap_up_thresholdadded toPromptsAgentRemindersConfigwith yaml, mapstructure, and env var supportagent_utils.go) and the sync agent loop (cmd/agent.go) correctly switch to wrap-up text when within the thresholdphase: "wrap_up"vs"periodic"for external observersconfiguration-reference.mdandchannels.mdupdatedModel:
ollama_cloud/deepseek-v4-flash· Exit Code:0· Duration: 6m 50sTokens: 3,274,544 in · 11,697 out · 3,286,241 total (51 requests)
Tool calls: 53 total · 100% success rate
Triggered by edenreich · Infer Action
fix: complete wrap-up reminder feature for #628
feat: add wrap-up reminders for agent mode (#628) (#635)
chore(release): 0.122.0 [skip ci]
inference-gateway-releaser commentedon Jun 20, 2026
🎉 This issue has been resolved in version 0.122.0 🎉
The release is available on:
Your semantic-release bot 📦🚀