Skip to content

ambient: session-end learnings rules + agent task-artifact writing#287

Open
Zpankz wants to merge 3 commits into
1jehuang:masterfrom
Zpankz:session-end-learnings-rules
Open

ambient: session-end learnings rules + agent task-artifact writing#287
Zpankz wants to merge 3 commits into
1jehuang:masterfrom
Zpankz:session-end-learnings-rules

Conversation

@Zpankz
Copy link
Copy Markdown

@Zpankz Zpankz commented May 31, 2026

What

Two complementary, opt-in/guidance-only enforcement layers for durable agent memory:

  1. Session-end learnings capture (Rules 1-8): documents the existing teardown
    extraction pipeline contract and wires an auditable on-exit ambient directive
    (record_session_end_directive) so capture is explicit, gated on
    ambient.enabled, and best-effort.

  2. Task artifact writing (Rule 9, this update): a "Task artifacts" section in
    the agent system prompt (crates/jcode-base/src/prompt/system_prompt.md)
    directs every jcode agent surface (TUI, server, swarm subagents, ambient) to
    write durable markdown artifacts to disk at the end of major tasks, mirroring
    the planning-with-files + memex file-writing pattern. Reaches all agents via
    build_system_prompt_split, which embeds DEFAULT_SYSTEM_PROMPT.

Design

  • Guidance + data, never executed as instructions. No breaking behavior change;
    no impact for users who have not opted in.
  • Reuses existing pipelines (run_final_extraction, ambient directives,
    system-prompt assembly) rather than inventing new ones.
  • Content discipline (durable, no diffs/hashes/build noise) mirrors the sidecar
    extraction prompt.

Files

  • docs/SESSION_END_LEARNINGS_RULES.md - 9 rules, 4 enforcement layers.
  • crates/jcode-base/src/prompt/system_prompt.md - "Task artifacts" section.
  • crates/jcode-app-core/src/ambient/directives.rs + ambient.rs - on-exit directive.
  • crates/jcode-tui/src/tui/app/conversation_state.rs - directive call site.

Verification

  • cargo build --profile selfdev -p jcode-base clean.
  • cargo test --profile selfdev -p jcode-base prompt - 18 passed.
  • session_end_directive_fields_format unit test for the directive helper.

Zpankz added 3 commits May 31, 2026 13:48
…sidecar fallback

Queried live provider catalogs via wired OAuth creds (Codex backend, Antigravity
cloudcode-pa, xAI) instead of relying on stale hardcoded lists. Documented
Pareto-optimal model->role assignments for every specialized agent role
(primary coding, swarm subagents, memory sidecar, autoreview, autojudge,
ambient) in docs/model-role-assignment.md, including a status table, a per-role
config example, and reproducible catalog-fetch commands.

gpt-5.4-mini is now live (272k ctx, cheaper/faster than gpt-5.4) so it is the
Pareto-better OpenAI sidecar fallback for the high-frequency relevance/extraction
workload. Added it to ALL_OPENAI_MODELS so the picker/catalog surface it.
Adds docs/SESSION_END_LEARNINGS_RULES.md: a series of rules formalizing what
the session-end learnings+work capture records (categories, dedup, trust,
no-ephemera, cost bounds) and how it is enforced across the pipeline,
extraction prompt, and ambient directive seed.

Wires Rule 8: trigger_save_memory_extraction (the /exit/quit teardown path)
now records an auditable, data-only session-end directive into the ambient
store when ambient mode is enabled. Best-effort; never blocks or fails
teardown. Adds record_session_end_directive + a unit test for the directive
format.

No behavior change for users without ambient enabled; reuses the existing
final-extraction pipeline rather than introducing a new one.
…jor tasks

Add a 'Task artifacts' section to the agent system prompt directing every
jcode agent surface (TUI, server, swarm subagents, ambient) to write durable
markdown artifacts to disk at the end of major tasks, mirroring the
planning-with-files + memex file-writing pattern. Reaches all agents via
build_system_prompt_split, which embeds DEFAULT_SYSTEM_PROMPT.

Document as Rule 9 in docs/SESSION_END_LEARNINGS_RULES.md and add a 4th
enforcement layer (agent system prompt). Guidance only: data, not executed
instructions; no breaking behavior change.
@Zpankz Zpankz changed the title ambient: enforce session-end learnings capture on /exit ambient: session-end learnings rules + agent task-artifact writing May 31, 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.

1 participant