Fresh session per task causes redundant project exploration, high token usage #150
Replies: 2 comments
-
|
fresh sessions per task is by design - this is the fundamental premise of ralphex, stated in the first line of README. each task gets a clean session to avoid context pollution and token bloat from accumulated history. regarding "most projects don't have one" ( "doesn't capture the dynamic context ralphex discovers during execution" - not accurate. the plan file with all task progress (checkboxes, completed items) and the automatically created progress file are both passed to each session. Claude sees what was already done. the claim about "significant chunk of tokens re-discovering" needs some evidence. in my experience with well-structured plans and proper if this is a real problem in a specific setup, solutions already exist without code changes:
all prompts and agents are fully customizable, see customization for details on editing task prompts, review prompts, and agents. pls use discussions for this type of questions |
Beta Was this translation helpful? Give feedback.
-
|
@slice-arpits this is exactly the class of failure I'm trying to document: the model can keep doing work, but every fresh task has to rebuild repo context and operational memory from scratch. If you're open to it, I'd value a short written postmortem here: https://www.agentsneedcontext.com/agent-failure-postmortem Most useful would be what each task had to rediscover, where that missing context actually lived ( |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Each task runs in a completely fresh Claude Code session (
claude -p), which means Claude has zero memory of the project between tasks. Every task re-explores the codebase from scratch - reading files, runninggit log, grepping for patterns, etc.For a 10-task plan on a medium-sized project, tasks 2-10 each spend a significant chunk of tokens just re-discovering what task 1 already learned about the project structure, key files, and architecture.
Where this happens:
pkg/executor/executor.go:174- freshclaude -pinvocation per taskpkg/processor/runner.go:336,384- same prompt sent every iteration, no accumulated contextThe plan file and progress file help Claude know what to do next, but they don't help it understand the project itself without re-exploring.
Possible approach
Generate a project context summary (e.g.
.ralphex/project-context.md) once at the start of a plan, then include it in subsequent task prompts. Could contain:This would be auto-generated by Claude in a dedicated "exploration" step before task 1, then referenced (not re-discovered) in tasks 2-10. Could cut per-task exploration overhead significantly.
Alternatively,
CLAUDE.mdpartially serves this role if the user maintains it, but most projects don't have one, and it doesn't capture the dynamic context ralphex discovers during execution.Beta Was this translation helpful? Give feedback.
All reactions