Repository navigation
feat(history): each subagent gets its own history file - #711
Conversation
Each subagent now gets its own history file in a dedicated history/ subdirectory, so subagent prompts no longer pollute the main agent's history when navigating with arrow keys. - Main agent: <configDir>/history/history - Subagents: <configDir>/history/history-<name> Adds NewShellHistoryWithName, NewHistoryManagerWithName, NewInputViewWithName, and CreateInputViewWithName — all accepting an optional name parameter. Legacy WithDir variants removed. Closes #699
When interactive subagents are launched via the Agent tool, they run `infer chat` in a tmux pane. Previously, the spawned `infer chat` created its input view with an empty name, causing the subagent's prompts (task descriptions typed into the subagent's TUI) to be written to the main agent's history file at <configDir>/history/history. This fix: 1. Adds INFER_SUBAGENT_HISTORY_NAME env var constant (subagent.go) 2. Sets this env var in buildChatPaneCommand (agent.go) using the subagent's label or session ID 3. Reads this env var in NewChatApplication (chat.go) and passes it to CreateInputViewWithName Now interactive subagents write to their own history files at: <configDir>/history/history-<label> <configDir>/history/history-<sessionID> Fixes #699
|
@claude Can you review this? |
|
Claude finished @edenreich's task in 4m 14s —— View job Review: per-subagent history files
Nice, focused change - the constructor refactor is clean, the legacy A few things worth addressing before merge: 🔴 1. The subagent label is used raw as a filename - not slugified (
|
Run the LLM-supplied subagent label through sanitizeSlug before using it as a history filename, so labels like "Refactor Auth" become dashcase and crafted labels (embedded ../) can no longer create malformed or directory-traversing files. Unlabeled subagents now use in-memory history (via the :memory: sentinel) instead of a per-spawn session-id file that left orphans in history/.
|
@claude Is it ready for merge now? are all the issues addressed? |
|
Claude finished @edenreich's task in 4m 47s —— View job PR readiness checkVerified the current branch state against the earlier review. All previously-raised items are addressed, tests pass (
Are the review issues addressed? Yes - all of them
The legacy One thing to decide before merge (new - not in the earlier review)🟡 Existing users lose their history and silently stop persisting it. The main history file moved from
It's not data loss (the old file is preserved) and it doesn't crash, but it's a backward-compat regression for existing users. Options: a small one-time migration in VerdictThe three review issues (and the nit) that were flagged are all correctly resolved - the slugify fix in particular closes both the dashcase-criteria gap and the path-traversal concern. Functionally the PR is solid and merge-ready on its own terms. The only thing I'd weigh is the migration edge case above. If the maintainer considers the personal history file low-stakes (degrades to a logged warning, easy manual fix), this can merge as-is with an upgrade note. If existing-user continuity matters, a ~10-line migration would close it cleanly. Your call. --- · |
|
@claude Is it ready for merge now? |
|
Claude finished @edenreich's task in 4m 2s —— View job Merge readiness check
Yes - it's ready to merge. ✅The last open item from the previous review (the backward-compat migration) has since been addressed by commit
The migration (
|
## [0.127.0](v0.126.0...v0.127.0) (2026-07-02) ### 🚀 Features * **plan:** compact context and start a fresh session when a plan is approved ([#705](#705)) ([28ddba7](28ddba7)) * **memory:** configurable git sync backend ([#707](#707)) ([6a68c3d](6a68c3d)), closes [#670](#670) [#670](#670) * **history:** each subagent gets its own history file ([#711](#711)) ([16c8fa1](16c8fa1)), closes [#699](#699) ### 🐛 Bug Fixes * **plan:** accepting a plan switches to auto-accept mode by default ([#714](#714)) ([7b0befc](7b0befc)), closes [#710](#710) * **tools:** guard concurrent gitignore and screenshot caches ([#713](#713)) ([0ff4276](0ff4276)), closes [#712](#712) * **tools:** guard Registry.tools with RWMutex against concurrent MCP registration ([#709](#709)) ([8a70871](8a70871)), closes [#708](#708) * **ui:** update dim color from [#565f89](https://github.com/inference-gateway/cli/issues/565f89) to [#7a7f9a](https://github.com/inference-gateway/cli/issues/7a7f9a) for improved contrast ([#706](#706)) ([b2ee67e](b2ee67e)) ### 🔧 Build System * **deps:** bump github.com/go-telegram/bot from 1.21.0 to 1.22.0 in the gomod group ([#703](#703)) ([3de5136](3de5136)) * **deps:** bump the github-actions group with 5 updates ([#704](#704)) ([80221f7](80221f7))
|
🎉 This PR is included in version 0.127.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Fixes #699 — each interactive subagent now gets its own history file in a dedicated
history/subdirectory, so subagent prompts no longer pollute the main agent's history when navigating with arrow keys.Changes
<configDir>/history/history<configDir>/history/history-<name>(e.g.history-refactor,history-research). The label is slugified (lowercased, dashcased, path-safe) before it is used as a filename.Files
internal/ui/history/shell_history.goNewShellHistoryWithName(configDir, name)— createshistory/history(main) orhistory/history-<name>(subagent). Removed legacyNewShellHistoryWithDir.internal/ui/history/history_manager.goNewHistoryManagerWithName(maxInMemory, configDir, name). Removed legacyNewHistoryManagerWithDir.internal/ui/components/input_view.goNewInputViewWithName(modelService, configDir, name); the:memory:sentinel selects in-memory history. Removed legacyNewInputViewWithConfigDir.internal/ui/components/factory/factory.goCreateInputViewWithName(modelService, configDir, name). Removed legacyCreateInputViewWithConfigDir.internal/app/chat.goCreateInputViewWithName.internal/agent/tools/agent.gospec.Label(viasanitizeSlug) before using it as the history name; unlabeled subagents get the memory-only sentinel instead of the per-spawn session id.internal/domain/subagent.goSubagentHistoryMemoryOnlysentinel value forINFER_SUBAGENT_HISTORY_NAME.internal/ui/history/shell_history_test.go.infer/history/history; addedTestNewShellHistoryWithName.internal/ui/history/history_manager_test.gohistory/subdirectory.internal/agent/tools/agent_test.goTestBuildChatPaneCommand_SlugifiesHistoryName.internal/ui/components/input_view_test.goTestNewInputViewWithName_HistorySelection.Acceptance Criteria
<userspace config dir>/history/history<userspace config dir>/history/history-<subagent name dashcase>