perf(prompt): cache kanban worker guidance at session init (#24402)#28425
Merged
Conversation
Salvages #24402 by @RyanRana. The KANBAN_GUIDANCE block (~835 tokens) is session-static — the dispatcher decides at spawn time whether the process is a kanban worker via the kanban_show tool's check_fn (gated on HERMES_KANBAN_TASK env var). Re-checking 'kanban_show' in valid_tool_names and re-loading the reference on every system-prompt rebuild (init + each context compression) is wasted work. Caches the resolved string on agent._kanban_worker_guidance once in agent_init and consumes it in system_prompt.build_system_prompt(), with a getattr fallback for code paths that bypass agent_init.
9 tasks
Contributor
🔎 Lint report:
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvages #24402 by @RyanRana.
KANBAN_GUIDANCEis session-static (dispatcher decides at spawn time whether this process is a kanban worker viakanban_showcheck_fn gating onHERMES_KANBAN_TASK). Re-checkingkanban_show in valid_tool_nameson every system-prompt rebuild (init + each compression) is wasted work.Caches the resolved string on
agent._kanban_worker_guidanceinagent_initand consumes it inagent.system_prompt.build_system_prompt().getattrfallback covers code paths that bypassagent_init(rare).Original branch was stale (the system-prompt code has since moved from
run_agent.pytoagent/system_prompt.py); applied the substantive caching pattern to current main's structure. Authorship preserved via rebase merge.