Skip to content

perf(prompt): cache kanban worker guidance at session init (#24402)#28425

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-de55f5dd
May 19, 2026
Merged

perf(prompt): cache kanban worker guidance at session init (#24402)#28425
teknium1 merged 1 commit into
mainfrom
hermes/hermes-de55f5dd

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages #24402 by @RyanRana.

KANBAN_GUIDANCE is session-static (dispatcher decides at spawn time whether this process is a kanban worker via kanban_show check_fn gating on HERMES_KANBAN_TASK). Re-checking kanban_show in valid_tool_names on every system-prompt rebuild (init + each compression) is wasted work.

Caches the resolved string on agent._kanban_worker_guidance in agent_init and consumes it in agent.system_prompt.build_system_prompt(). getattr fallback covers code paths that bypass agent_init (rare).

Original branch was stale (the system-prompt code has since moved from run_agent.py to agent/system_prompt.py); applied the substantive caching pattern to current main's structure. Authorship preserved via rebase merge.

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.
@teknium1 teknium1 merged commit 206f595 into main May 19, 2026
@teknium1 teknium1 deleted the hermes/hermes-de55f5dd branch May 19, 2026 03:56
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-de55f5dd vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8815 on HEAD, 8815 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4627 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/perf Performance improvement or optimization P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder comp/plugins Plugin system and bundled plugins labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants