Skip to content

feat(agent): add disable_history_injection config option#3201

Open
wyjBot wants to merge 15 commits intoHKUDS:nightlyfrom
wyjBot:feat/disable-history-injection
Open

feat(agent): add disable_history_injection config option#3201
wyjBot wants to merge 15 commits intoHKUDS:nightlyfrom
wyjBot:feat/disable-history-injection

Conversation

@wyjBot
Copy link
Copy Markdown
Contributor

@wyjBot wyjBot commented Apr 16, 2026

Summary

  • Adds disable_history_injection: bool = False to AgentDefaults in config/schema.py
  • ContextBuilder stores the flag and skips the # Recent History block in build_system_prompt when it is true
  • AgentLoop forwards the flag from its constructor to ContextBuilder
  • NanoBot.from_config passes defaults.disable_history_injection to AgentLoop

Motivation

On every turn, build_system_prompt automatically appends a # Recent History section sourced from history.jsonl (up to 50 entries). For agents with long-running histories or privacy-sensitive workspaces, this can:

  • Inflate prompt size / cost on every turn
  • Feed stale or irrelevant diary entries into a focused task session
  • Interfere with clean-slate conversations (e.g. short-lived bot sessions)

There was previously no way to opt out without patching source code. This PR exposes a first-class config knob.

Usage

// config.json
{
  "agents": {
    "defaults": {
      "disable_history_injection": true
    }
  }
}

Default is false, so existing behaviour is fully preserved.

Test plan

  • AgentDefaults() has disable_history_injection=False by default
  • ContextBuilder(workspace, disable_history_injection=True).build_system_prompt() produces a prompt without # Recent History
  • ContextBuilder(workspace, disable_history_injection=False).build_system_prompt() still includes history entries when present
  • Full test suite passes (225 passed, 4 skipped)

🤖 Generated with Claude Code

chengyongru and others added 15 commits April 14, 2026 00:37
Feishu streaming cards auto-close after 10 minutes from creation,
regardless of update activity. With resuming enabled, a single card
lives across multiple tool-call rounds and can exceed this limit,
causing the final response to be silently lost.

Remove the _resuming logic from send_delta so each tool-call round
gets its own short-lived streaming card (well under 10 min). Add a
fallback that sends a regular interactive card when the final
streaming update fails.
When deliver: false is set in cron job payload, suppress all output even
when agent calls message tool during the turn.

Closes HKUDS#3115
Add a built-in tool that lets the agent inspect and modify its own
runtime state (model, iterations, context window, etc.).

Key features:
- inspect: view current config, usage stats, and subagent status
- modify: adjust parameters at runtime (protected by type/range validation)
- Subagent observability: inspect running subagent tasks (phase,
  iteration, tool events, errors) — subagents are no longer a black box
- Watchdog corrects out-of-bounds values on each iteration
- Enabled by default in read-only mode (self_modify: false)
- All changes are in-memory only; restart restores defaults
- Comprehensive test suite (90 tests)

Includes a self-awareness skill (always-on) with progressive disclosure:
SKILL.md for core rules, references/examples.md for detailed scenarios.
PyJWT and cryptography are optional msteams deps; they should not be
bundled into the generic dev install.  Tests now skip the entire file
when the deps are missing, following the dingtalk pattern.
Warn when validate_inbound_auth is disabled (default) so operators are
aware the webhook accepts unverified requests.  Restore pymupdf to the
dev optional-dependencies group — its removal in the original PR was
unrelated to the Teams channel feature.
- Check both jwt and cryptography in MSTEAMS_AVAILABLE guard so
  partial installs fail early with a clear message instead of at runtime
- Add aclose() to test FakeHttpClient so stop() won't crash
- Move MSTEAMS.md into README.md following the same details/summary
  pattern used by every other channel
- Note in README that validateInboundAuth defaults to false
Introduce `AgentDefaults.disable_history_injection` (default `false`).
When set to `true`, the `# Recent History` block derived from
`history.jsonl` is omitted from the system prompt, giving users full
control over whether unprocessed history entries are auto-injected into
each conversation turn.

Changes:
- `config/schema.py`: new `disable_history_injection: bool = False` field on `AgentDefaults`
- `agent/context.py`: `ContextBuilder` accepts and stores the flag; `build_system_prompt` skips the history block when it is set
- `agent/loop.py`: `AgentLoop.__init__` accepts and forwards `disable_history_injection` to `ContextBuilder`
- `nanobot.py`: `NanoBot.from_config` passes `defaults.disable_history_injection` to `AgentLoop`

Usage in `config.json`:
```json
{
  "agents": {
    "defaults": {
      "disable_history_injection": true
    }
  }
}
```

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Re-bin Re-bin deleted the branch HKUDS:nightly April 19, 2026 16:21
@Re-bin Re-bin closed this Apr 19, 2026
@chengyongru chengyongru reopened this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants