Skip to content

feat: Deterministic Agent Callbacks Model-Initiated Control Umbrella - Unleash the CLI in opencode#20074

Open
micuintus wants to merge 4 commits intoanomalyco:devfrom
micuintus:feat/DACMICU_20018
Open

feat: Deterministic Agent Callbacks Model-Initiated Control Umbrella - Unleash the CLI in opencode#20074
micuintus wants to merge 4 commits intoanomalyco:devfrom
micuintus:feat/DACMICU_20018

Conversation

@micuintus
Copy link
Copy Markdown

Issue for this PR

Closes #20018

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Closes #20018 — Enter DACMICU = Deterministic Agent Callbacks — Model-Initiated Control Umbrella

The heart of this PR: It introduces a CLI tool (oc) that "calls back into opencode"

  • This enables the model to write bash (or python) scripts that can make tool and LLM calls, orchestrating the control flow

Idea: Unleash the full power of the UNIX CLI in opencode, see #20018

  1. LLMs are good at figuring out things and generating code
  2. LLMs are bad at:
  • Iterations — they lose count, skip steps, forget where they were
  • Following through — they lose track of the control flow once grinding too much on one aspect
  • Deterministic control flow — loops, conditionals, batch operations are something LLMs are really bad at

Three Use Cases

1. Ralph Loop — delegate entire task, re-verify until clean

while oc check "Look at this branch, check for bugs, security issues, check unit tests. Fix everything and commit."; do
  oc status "Review round complete — re-checking..."
done

2. Fabric-style pipes — AI judgment in Unix pipelines

find src/ -name "*.ts" | while read f; do
  cat "$f" | oc prompt -s "Code reviewer" "Rate complexity 1-10. Just the number."
done | sort -rn | head -10

3. Deterministic batch with opencode tools

oc tool glob "src/**/*.ts" | while IFS= read -r f; do
  oc tool edit "$f" --old "getUserData" --new "getUser"
done

How did you verify your code works?

  • A comprehensive list of unit tests has been added (along the way when discovering issues)
  • Intensive manuel testing

Screenshots / recordings

Fabric

SR.DACMICU.Fabric_compressed.mov

Sorry for the token waste :D, but the reason I let it run on 243 files was to make the point:

  • A standard agent would have never followed through summarising all of the paper
  • and wasted way more tokens and taken way much longer for such a task.
Screenshot 2026-03-30 at 16 36 44

Ralph Loop

Example 1:

Screenshot 2026-03-29 at 17 47 03 Screenshot 2026-03-30 at 12 33 44

Another run (both with Sonnet)

Screenshot 2026-03-29 at 17 46 18

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Feat: Deterministic Agent Callbacks Model-Initiated Control Umbrella - Unleash the CLI in opencode doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@micuintus micuintus changed the title Feat: Deterministic Agent Callbacks Model-Initiated Control Umbrella - Unleash the CLI in opencode feat: Deterministic Agent Callbacks Model-Initiated Control Umbrella - Unleash the CLI in opencode Mar 30, 2026
@micuintus micuintus force-pushed the feat/DACMICU_20018 branch 2 times, most recently from eb3cf77 to 7d30c93 Compare March 30, 2026 19:24
- Handle sync plugin hooks in Effect.promise
- Update turbo to v2.8.21 to resolve socket error
- Remove dead scripts from package.json
Implement the DACMICU pattern — deterministic agent callbacks with
model-initiated control. The LLM writes bash scripts that call back
into the running openCode instance via the oc command.

- Add bin/oc shell wrapper and bin/oc.ts TypeScript implementation
- Add /session/:id/exec endpoint for AI judgment (child sessions)
- Add /session/:id/tool endpoint for direct tool execution (no LLM)
- Integrate oc env vars into bash tool (server URL, session, PATH)
- Add oc scripting guidance to system prompt
- Add TodoReadTool for oc todo list support
- Add MessageV2.model() for parent session model inheritance
- Add followUp schema for oc check boolean evaluation
- Add TUI visibility for oc calls (ToolParts with metadata.oc)
- Fix subagent navigation direction and naming conventions
- Disable timeout for any script containing oc commands
- Skip timer entirely when timeout is 0 (DACMICU mode)
- Add dacmicu.test.ts: CLI unit tests, binary protocol, shell fast-path,
  oc check sentinel detection, keepalive protocol
- Add ralph-loop-timeout.test.ts: AST-based oc command detection,
  timeout configuration per command type
- Add dacmicu-endpoints.test.ts: /tool and /exec endpoint integration
  tests, ToolPart creation, binary file pass-through, followUp schema
- Add oc.test.ts: exec timeout regression tests
- Add message-v2.test.ts and bash.test.ts: extended coverage for
  MessageV2 and bash tool changes
- Fix compaction test to match Stream.mapEffect signature change
- Add specs/DACMICU.md: full design document covering the four pillars
  (Manus CLI, deterministic split, Ralph Loop, Fabric composition),
  architecture, competitive landscape, and adoption strategy
- Add test/eval/dacmicu-adoption.sh: measures LLM adoption rate across
  5 prompt patterns with scoring (0/1/2 per prompt)
- Add test/eval/dacmicu-fast.sh: lightweight 3-prompt eval for quick
  iteration testing
@micuintus micuintus force-pushed the feat/DACMICU_20018 branch from 7d30c93 to 8e288cf Compare March 30, 2026 19:24
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.

[FEATURE]: Unleash the full power of the CLI: Callback to the LLM/agent from scripts

1 participant