feat(agents): inject trail context into the model when trails are enabled

main

Commit

dipree3mo ago

Add a ContextInjector capability so Entire teaches an agent about the entire trail command by injecting a one-line note into the model's context window (distinct from HookResponseWriter, which targets the user).

The dispatcher emits it once per session via strategy.ClaimContextInjection, claiming first so the trails-enabled probe runs at most once per session, and only when trails are literally enabled for the repo on the API (api.Client.TrailsEnabled probes the trails endpoint; 2xx => enabled).

Per-transport injection at TurnStart:

  • Claude Code / Codex / Gemini: hookSpecificOutput.additionalContext (UserPromptSubmit / BeforeAgent), via RenderAdditionalContextHookOutput
  • Pi: {"inject_context":...} envelope -> before_agent_start hidden message
  • OpenCode: envelope captured from turn-start stdout -> appended to the system prompt via experimental.chat.system.transform

Injected string: "A trail ties together the context for a branch. Use entire trail to view, create, update, or watch it."

Entire-Checkpoint: 300c2bf2384f

Checkpoints

Inject Trail Context into Agent Model

PiOpus 4.8
View session
Checkpoint 1