claude-code - 💡(How to fix) Fix [FEATURE] Predictive agentic loop

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  1. I can now "measure" the difference between <P> and <R>. If <P> and <R> are roughly equal all is ok. If not then I can do stuff with it - store it as memory, act on it because it's some kind of exception, ....

Root Cause

Try as I might I can't get Claude Code to work in this loop currently because no matter what I do, he'll stop following this loop after some time (or worse, he follows it only partially). So I'm left by creating my own LLM wrapper (which I obviously don't want to do) or ask you guys for it.

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

I'd like to have the possibility to switch the standard Claude Code agentic loop (https://code.claude.com/docs/en/agent-sdk/agent-loop) to a predictive one (instead of reactive) and be able to connect my hooks before/after every action in that loop. What is meant by that - I'd like Claude Code to make a prediction of what the next prompt will be (or what the next reply from a tool will be

<img width="709" height="450" alt="Image" src="https://github.com/user-attachments/assets/6c4d14f0-d296-43c8-b35f-24062ce4c639" />

Try as I might I can't get Claude Code to work in this loop currently because no matter what I do, he'll stop following this loop after some time (or worse, he follows it only partially). So I'm left by creating my own LLM wrapper (which I obviously don't want to do) or ask you guys for it.

Proposed Solution

As described in the previous screenshot I'd like Claude Code to make a prediction of what the next output will be like. With that prediction I gain abilities far beyond reactive reasoning - with prediction of what will happen I can react to surprise, detect anomalies, know what makes sense to memorize in context etc etc - hence I need this.

Alternative Solutions

I've tried putting this loop into start up instruction but after couple of exchanges Claude won't follow the loop. SOmetimes it tells me it's following the loop but I see it's not so I need to ask explicitly.

I tried adding hooks on startup to execute this loop - same result.

But I think it needs to be hardcoded in the main agentic loop and I can't change that one.

Priority

Medium - Would be very helpful

Feature Category

Interactive mode (TUI)

Use Case Example

  1. I ask Claude to do something, he makes a prediction <P> what I'll ask from him/what the result of using a tool/what my next prompt will be
  2. Tool returns result <R> or I enter a second prompt <R>
  3. I can now "measure" the difference between <P> and <R>. If <P> and <R> are roughly equal all is ok. If not then I can do stuff with it - store it as memory, act on it because it's some kind of exception, ....

Additional Context

LLMs themselves are based on prediction and you see where it lead. I need to use predictions but for some reason the agentic loop is "only" reactive for now

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING