Skip to content

Request for system prompt / complete context in preRequest hook #358

@rschmukler

Description

@rschmukler

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

I've been building a persistent memory system that hooks into ECA via chatStart + preRequest to inject recalled memories into the prompt. It works well, but I've run into a limitation with the preRequest hook that makes deduplication harder than it needs to be.

Each preRequest invocation is a fresh process - it only gets { hook_type, prompt }. I want to avoid re-injecting memories the agent has already seen, but I have no way to know what's currently in the conversation context. Right now I'm working around this with a statefile that tracks what I've surfaced, but it's blind to context compaction; if ECA truncates older context, those memories should be re-surfaced, but my statefile still thinks they're present.

The opencode plugin doesn't have this problem because its hook receives the full system prompt state, so it can scan for what's already there.
What would help: If the preRequest payload included the current conversation messages (or at least the system prompt / injected context entries), the hook could inspect what's actually present and make smarter decisions. Something like:

{
  "hook_type": "preRequest",
  "prompt": "...",
  "messages": [
    { "role": "system", "content": "..." },
    { "role": "user", "content": "..." },
    { "role": "assistant", "content": "..." }
  ]
}

Even a lighter version would work, just the system/injected context entries, not the full message history. The key thing is being able to see what the model will actually receive, so hooks can avoid redundancy and respond to compaction. Any hook that wants to inject contextual information (RAG, memory, project state, etc.) benefits from knowing what's already in the context. Without it, you either accept duplicates (wasting tokens) or maintain fragile external state that can't account for compaction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions