#Need help condensing system prompt

1 messages · Page 1 of 1 (latest)

valid breach
#

My initial prompt has ballooned to 17000 tokens. Please help to reduce this

untold fjordBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

small lanternBOT
#

Yep — 17k tokens is too much for an initial prompt. I’d reduce it in this order:

  1. Delete duplication

    • Remove anything OpenClaw already injects by default.
    • Don’t repeat tool descriptions, safety boilerplate, or long examples.
  2. Split “rules” from “reference”

    • Keep only hard behavior rules in AGENTS.md.
    • Put persona/tone in SOUL.md.
    • Put durable user/project facts in MEMORY.md.
    • Put local tool quirks in TOOLS.md.
  3. Turn prose into bullets

    • Bad: long paragraphs explaining philosophy.
    • Good: Always do X, Never do Y, When Z, do A before B.
  4. Move rare info out of prompt

#
  • If it’s only needed occasionally, store it in memory/docs and make the agent search/read it when needed.
    • Don’t preload giant reference material every turn.
  1. Use OpenClaw context controls
    Useful knobs:
    {
      agents: {
        defaults: {
          contextInjection: "continuation-skip",
          bootstrapMaxChars: 6000,
          bootstrapTotalMaxChars: 20000
        }
      }
    }
    
    continuation-skip can reduce repeated bootstrap injection on normal continuation turns.
valid breach
small lanternBOT
#

I looked at the paste. Good news: this is not all your custom initial prompt.

The bloat is mostly coming from:

  1. Conversation history being resent — lots of repeated hi / Heyyy turns.
  2. Tool schemas — cron, edit, exec, message, etc. are included in the request.
  3. Memory/runtime context leaking into assistant messages — I see repeated OpenClaw runtime context... / <relevant-memories> inside prior assistant messages, which then get saved and resent again. That’s the nasty part. (ctxt.io)

I’d do this first:

{
  agents: {
    defaults: {
      contextInjection: "continuation-skip",
      bootstrapMaxChars: 4000,
#
      bootstrapTotalMaxChars: 12000,

      experimental: {
        localModelLean: true,
      },
    },
  },

  tools: {
    profile: "minimal"
  },

  plugins: {
    entries: {
      "active-memory": {
#
        enabled: true,
        config: {
          queryMode: "message",
          maxSummaryChars: 120,
          recentUserTurns: 1,
          recentAssistantTurns: 0,
          persistTranscripts: false
        }
      }
    }
  },

  memory: {
    qmd: {
      limits: {
valid breach
#

doing a /new and cleanup and restart and will then send what is injected

small lanternBOT
#

Sounds good. After /new + restart, send:

openclaw --version
openclaw status --all

And if you paste the injected request again, try to include:

  • the system message start/end
  • the messages array length
  • the tools list count/names
  • whether OpenClaw runtime context... or <relevant-memories> still appears inside assistant history

If that runtime/memory block still appears in assistant messages after a fresh session, that’s the key bug to chase.

valid breach
#

could this be a problem?

"contextInjection": "always",

small lanternBOT
#

Yes — it can absolutely be part of the problem.

contextInjection: "always" means OpenClaw injects your workspace bootstrap files every turn: AGENTS.md, SOUL.md, USER.md, TOOLS.md, MEMORY.md/context files, etc. If those files are large, your “initial prompt” will stay large even after /new.

Try:

{
  agents: {
    defaults: {
      contextInjection: "continuation-skip"
    }
  }
}

That keeps startup behavior, but skips re-injecting bootstrap context on safe continuation turns.

#

I would not jump straight to "never" unless you know your agent doesn’t need those files injected, because that can make it forget your workspace/persona rules.

Docs: https://docs.openclaw.ai/gateway/config-agents

Still, always alone doesn’t explain OpenClaw runtime context... showing up inside old assistant messages — that looks like transcript pollution or active-memory/runtime context being persisted into the visible assistant history. So: switch to continuation-skip, restart, /new, then check the injected request again.

valid breach
#

continuation-skip

what does this do? vs always? explain

small lanternBOT
#

contextInjection controls whether OpenClaw re-adds your workspace bootstrap files into the prompt.

Those are things like:

  • AGENTS.md
  • SOUL.md
  • USER.md
  • TOOLS.md
  • IDENTITY.md
  • HEARTBEAT.md
  • maybe other context/memory-style bootstrap material depending on setup

"always"

contextInjection: "always"
#

Means: inject those files every model turn.

So if your workspace files are 10k tokens, they keep getting added again and again on every normal reply.

Good for maximum consistency. Bad for token usage.

"continuation-skip"

contextInjection: "continuation-skip"

Means: inject them when starting/rebuilding context, but skip re-injecting them on safe follow-up turns after the assistant already replied successfully.

So the agent still gets its bootstrap/persona/rules at session start, but OpenClaw doesn’t keep stuffing the same files into every continuation request.

This is usually the better default if your prompt is ballooning.

#

Important: it only reduces workspace context injection. It does not remove:

  • tool schemas
  • conversation history
  • active-memory summaries
  • model/provider runtime messages

So I’d set:

{
  agents: {
    defaults: {
      contextInjection: "continuation-skip"
    }
  }
}
valid breach
#

but the agent would still remember the workspace files right?