Skip to content

[Feature Request]: A run-derived improvement loop for DeepCode (human-in-the-loop) #310

Open

Description

@raymondginger2018-sudo
  • I have searched the existing feature request and this feature request is not already filed.
  • I believe this is a legitimate feature request, not just a bug or question.

Feature Request Description

I’d like to propose a concrete framing for the RSI direction you mentioned in #303.

What I mean by RSI: not autonomous self-modification. A closed loop where the agent’s own runs produce artifacts that are reviewed, versioned, and then improve the next runs. Human-in-the-loop, opt-in, fail-safe. The agent does not edit its own code; it produces evidence and candidate improvements that a maintainer can accept or reject.

CONTRIBUTING.md says larger changes should start with an issue. This is that issue: three candidate directions, no code yet.

Direction A — failure-to-regression corpus

Problem: failed runs (tool errors, bad permission decisions, failed tests) are observed but not turned into durable regressions. The next run can repeat the same failure.

Mechanism: on a failed session, extract a minimal trace (tool sequence, inputs, error signature, context fingerprint), redact secrets/PII, and emit a replayable regression case. The corpus is a local, human-reviewed artifact and can be replayed by the existing test/CI harness before and after changes.

Consumer: the existing pytest/CI path (scripts/ci_scope.py, run-ci-jobs.sh) and optionally a deepcode replay command. Not a new runtime framework.

Minimal first step: a script that converts one failed session into one pytest fixture plus a short README. No core changes. If it proves useful, it can be a test-only PR (the shape that worked for #297).

Open questions: where should the corpus live (tests/ vs a new top-level dir)? What is the minimal trace schema? How do we prevent PII/secrets from entering it?

Direction B — success-trace playbooks

Problem: successful runs contain reusable strategies (tool order, recovery moves, permission decisions) that are lost after the session.

Mechanism: mine successful traces for recurring playbooks; store them as versioned, human-approved skill/policy files with provenance; retrieve by context signature; A/B evaluate before enabling. Reuse the existing memory/context path (core/harness/memory.py, AgentRunSpec / AgentSession), not a new framework.

Consumer: AgentRunSpec / AgentSession context injection; ToolRegistry hints; the shared session path used by app_server/TUI/Desktop/Web.

Minimal first step: an offline script over saved sessions that outputs candidate playbooks plus a diff-style A/B report. No runtime change until the output is useful.

Open questions: what is a “playbook” (text, tool sequence, or policy)? How do we avoid overfitting to one repository? How do we revoke a bad playbook?

Direction C — counterfactual replay for change promotion

Problem: prompt/tool-description/permission changes are evaluated ad hoc. #302 was closed because it had no consumer. This direction gives the evaluator a concrete consumer: a maintainer-invoked CLI that replays a fixed set of past sessions against two variants and prints capability/efficiency metrics.

Mechanism: deepcode eval replay --baseline ... --candidate ... over saved sessions; compare success/error/token/steps; no auto-promotion. Sandboxed, deterministic, no network side effects by default.

Consumer: maintainers deciding whether to merge a prompt/tool/permission change; CI can run a small fixed subset.

Minimal first step: CLI + report over 3–5 saved sessions; no core runtime change.

Open questions: which sessions are safe to replay (no external side effects)? How do we keep it deterministic? Is a CLI acceptable, or should it live in scripts/?

Additional Context

What I am not proposing:

  • no autonomous code edits or self-modifying runtime;
  • no new framework module without a runtime consumer;
  • no external project references or benchmark codes;
  • no big PR. Start with one direction and one small artifact.

Relevant existing pieces: core/agent_runtime/runner.py (AgentRunSpec, compaction), core/events/session.py (AgentSession, compaction summary sink), core/harness/memory.py, core/agent_runtime/tools/registry.py (ToolRegistry), core/agent_runtime/evidence_ledger.py, and the shared app_server/TUI/Desktop/Web session path.

What I’d like from you:

  1. Which direction fits the roadmap (A/B/C), or is there a different framing you prefer?
  2. For the chosen direction, is the first step better as an issue-level prototype, a scripts/ tool, or a test-only PR?
  3. What would count as a convincing A/B result before touching runtime?

I checked the existing issues for “RSI”, “recursive self-improvement”, and “self-improvement”; none matched, so I’m opening this as a design discussion rather than a code PR.

Activity

  1. raymondginger2018-sudo commented on Nov 19, 2026

    @raymondginger2018-sudo
    ContributorAuthor

    Thanks for framing this as a run-derived loop. Reading the maintainer's note on #303 (RSI, "bold ones are welcome") it seemed to me the missing half is not how to propose an edit but what to carry forward between runs, so I spent today on that.

    What the recent work says. arXiv:2611.18856 (Google Cloud AI / DeepMind / Penn State, Nov 13) names the failure mode concretely: when the policy model or benchmark changes we carry the evolved harness but not the reasoning behind each edit — rationale, which failures it was meant to fix, whether it did, and on which model/benchmark. Two measured consequences: an Opus-evolved harness starts below Gemini's own seed on Gemini (68.41 vs 73.89), and a source-evolved FewShotAll harness starts below its seed on the target suite (72.92 vs 75.72). Their ablation also matters for design: keeping only root causes is mixed (−1.82 to +2.40 vs harness-only), i.e. the edit history and outcomes are the part that pays.

    The shape I implemented locally. One JSON ledger, edits grouped by recurring problem; each attempt records predicted before evaluation, then fixed/missed after, plus provenance (domain, round). Top level carries carried_from and aliases so a target run inherits and can merge. Two call points only: proposal time freezes the prediction, gate time fills in the observation. No similarity model for matching — the paper has the proposer decide, and an embedding match would add unreproducible state we would then have to trust.

    A first signal (n=1, proxy metrics — not a benchmark claim). Real local models, same harness interface, source qwen3:14b → target qwen2.5-coder:14b:

    • target without the ledger repeated the source's suggestion closely (text ratio 0.537);
    • target with the ledger did not (0.194) and moved to a different, more root-level edit.

    I also ran deepseek-r1:14b as the target and got a null: both conditions produced unparseable output and fell back to boilerplate. That is a capability floor rather than a memory effect, and worth knowing before anyone reads a gain into this.

    Honest limits: n=1, the corpus was reconstructed from a real incident (our signal store happened to be empty), and the quality gate rejected both proposals — so this shows the mechanism runs, nothing more.

    The question. Is this the shape you would want for a run-derived loop — problem-grouped attempts with prediction/observation/provenance carried across model changes — or would you rather this stay a local script over saved sessions, the route suggested for #301? I would rather align on the shape than write something that misses it.

  2. raymondginger2018-sudo commented on Nov 19, 2026

    @raymondginger2018-sudo
    ContributorAuthor

    Follow-up, correcting my own previous comment: the single-run difference I reported does not hold up, so please don't read it as a signal.

    I ran the same comparison as ten paired continuations (ten different 3-signal windows drawn from the same reconstructed incident family; same source model, same target model, same single round and budget per condition). Result on the same proxy — how closely the target's edit repeats the source's edit:

    • mean difference +0.021, 95% CI [−0.050, +0.092], sd 0.099
    • 4 wins / 6 losses across the ten pairs
    • the quality gate rejected all twenty target proposals, in both conditions

    So the earlier 0.537 → 0.194 was sampling variance, not an effect of carrying the memory. One run can produce a tidy-looking direction; ten runs do not.

    Two caveats on my side, in the interest of not over-reading this in either direction:

    1. The proxy may have no dynamic range. Both conditions landed in 0.12–0.43, i.e. the target model rarely restates the source edit verbatim whether or not it has the record — which makes this metric unable to resolve a difference. So "no measurable effect here" is not "no effect".
    2. A meaningful test needs a task-level success criterion, which we do not currently have an equivalent of; that is the part I cannot supply locally.

    What does stand, from our side: the mechanism runs end to end — predictions are written before evaluation, outcomes are filled in after, and the record survives a model change. That is all I would claim.

    The design question from my earlier comment still stands, and it matters more than the numbers: is a problem-grouped attempt ledger with prediction/observation/provenance the shape you would want, or would you rather this remain a local script over saved sessions? If it is the latter, I'll stop here rather than build a benchmark harness around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions