# Shared Context (v4.0)

Shared-context is a file-based coordination layer that multiple agents can read/write, enabling cross-agent collaboration without direct agent-to-agent messaging.

Default location:
- `~/.openclaw/workspace/shared-context/`

Override:
- `sharedContextDir`

Enable:
- `sharedContextEnabled: true`

## Directory Structure

- `priorities.md`: curated living priority stack (agents read before acting)
- `priorities.inbox.md`: append-only inbox for new priority notes
- `agent-outputs/<agent>/<YYYY-MM-DD>/*.md`: work products written by agents
- `feedback/inbox.jsonl`: append-only approvals/rejections with optional learning/outcome
- `roundtable/<YYYY-MM-DD>.md`: daily synthesis written by the curator tool
- `cross-signals/<YYYY-MM-DD>.md`: human-readable recurring themes, risks, and promotion candidates with provenance
- `cross-signals/<YYYY-MM-DD>.json`: deterministic overlap report (topics/entities) across daily outputs + feedback totals

## Tools

- `shared_context_write_output`
- `shared_priorities_append`
- `shared_feedback_record`
- `shared_context_cross_signals_run`
- `shared_context_curate_daily`

`shared_context_cross_signals_run` writes:
- cross-signal markdown (`cross-signals/<YYYY-MM-DD>.md`)
- cross-signal JSON (`cross-signals/<YYYY-MM-DD>.json`)

`shared_context_curate_daily` now writes:
- roundtable markdown (`roundtable/<YYYY-MM-DD>.md`)
- cross-signal markdown (`cross-signals/<YYYY-MM-DD>.md`)
- cross-signal JSON (`cross-signals/<YYYY-MM-DD>.json`)

Cross-signal report includes:
- per-source topic token extraction (from title/body)
- overlap entries where the same token appears across 2+ agents
- daily feedback decision totals (`approved`, `approved_with_feedback`, `rejected`)
- optional semantic overlap enhancement metadata (`semantic.enabled/applied/timedOut`)

Roundtable output includes a `Cross-Signals` section summarizing:
- number of sources analyzed
- number of feedback entries analyzed
- decision totals
- semantic enhancer status (disabled/applied/no-additional-overlap/timeout fail-open)
- paths to the generated cross-signal markdown + JSON
- top overlap bullets when available

Semantic enhancer settings (all optional):
- `sharedCrossSignalSemanticEnabled` (default `false`)
- `sharedCrossSignalSemanticTimeoutMs` (default `4000`)
- `sharedCrossSignalSemanticMaxCandidates` (default `120`)

Compatibility aliases remain supported:
- `crossSignalsSemanticEnabled`
- `crossSignalsSemanticTimeoutMs`

Injection:
- When enabled, Engram injects `priorities.md`, the latest `roundtable/*.md`, and the latest `cross-signals/*.md` into the system prompt (timeboxed and capped by `sharedContextMaxInjectChars`).
- Shared context is assembled at **position 1** in the recall pipeline — before profile and memories. It consumes recall budget first.

### Budget interaction

With the default `recallBudgetChars` of 8,000 and `sharedContextMaxInjectChars` of 6,000, shared context plus profile (~7,500 chars) can exhaust the entire budget, leaving zero room for actual memories. If you enable shared context, set `recallBudgetChars` to at least 32,000 (or 64,000+ for large-context models). See [Recall Budget Tuning](config-reference.md#recall-budget-tuning).

## Scheduling

Run `shared_context_curate_daily` as an isolated cron agent turn (recommended) near the end of your day.
