Skip to content

Auto context management on subagents mode#147

Open
pedrosimao wants to merge 13 commits into
gotalab:mainfrom
pedrosimao:manage-context
Open

Auto context management on subagents mode#147
pedrosimao wants to merge 13 commits into
gotalab:mainfrom
pedrosimao:manage-context

Conversation

@pedrosimao

Copy link
Copy Markdown

This PR is an initial implementation for the following issue:

#140

It modifies the spec-impl commands so it spawns subagents, that self manage their own context usage. In case of big context usage the subagent stops itself and the orchestrator spawns a new subagent with same promp, plus some handoff instructions.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91e25b0b55

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tools/cc-sdd/src/hooks/context-monitor/statusline-writer.ts Outdated
Comment thread tools/cc-sdd/templates/agents/claude-code-agent/agents/spec-impl.md Outdated
@gotalab

gotalab commented Mar 7, 2026

Copy link
Copy Markdown
Owner

@pedrosimao
Thanks for the PR!

Could you please make these two changes?

  • For the command file name, we’d like to keep spec-impl (kiro-spec-impl) as is, and add ralph-impl (kiro-ralph-impl) with that naming.
  • The agent directory for OpenCode should be .opencode/agents/.

This is related to some ongoing work here as well:
#141

@pedrosimao

Copy link
Copy Markdown
Author

@pedrosimao Thanks for the PR!

Could you please make these two changes?

* For the command file name, we’d like to keep `spec-impl` (`kiro-spec-impl`) as is, and add `ralph-impl` (`kiro-ralph-impl`) with that naming.

* The agent directory for OpenCode should be `.opencode/agents/`.

This is related to some ongoing work here as well: #141

Yes, no problem. I actually thought about making a separate command for this. So people can experiment with efficiency of both methods.
For me a critical part of implementing the ralph loop is not the infinite iteration itself, but the fact that the Agents should keep the context usage to a reasonable amount. Some models even announce 1 million context window, but the LLM becomes less efficient at coding after even 100k tokens.
Also, on my implementation I made in a way that each subagent will be responsible for a sub-task, and not entire tasks. So, I did not worry about limiting the loop iterations too much.
I am not sure how we can do reconciliation on our different ideas.
Finally, do you really think SKILLS are needed? I feel like skills are of great value when its something we want to bring to context from time to time, or when it has some kind of script.
If we are always using the same SKILL with the same command, maybe it is easier to just integrate it into the agent prompt itself.

@gotalab

gotalab commented Mar 8, 2026

Copy link
Copy Markdown
Owner

@pedrosimao
That makes sense, and I agree that keeping context usage under control is one of the most important parts of a Ralph-style loop.

For this project, the iteration limit is mainly a safety guard to prevent non-deterministic agent's behavior from getting stuck in an infinite loop. It is not the main mechanism for controlling efficiency.

Since cc-sdd adopts Kiro-style SDD, it is difficult to fully eliminate the limitations of SDD itself. What we can do is optimize around it. In practice, I think the most important part is coverage: whether each decomposed sub-task remains aligned with the approved requirements and design.

About Agent Skills, I think they are needed for cc-sdd:

  • cc-sdd aims to work across multiple agents, so supporting an open standard like Agent Skills is more valuable than relying on specific agent features.
  • Skills let users reuse their own context-dependent assets across projects and agents, such as Playwright CLI, testing workflows, review checklists, and deployment procedures.
  • In agents like Claude Code and Codex, skills are supported as a first-class mechanism, and those platforms provide controls over whether and how a skill is invoked, rather than forcing everything to be always-on in the base agent instructions.

@pedrosimao

Copy link
Copy Markdown
Author

@gotalab regarding the context management, the original claude ralph loop plugin does not do it. Which is not what the original creator of the ralph loop proposed. So, I would vote against using this plugin, or mentioning it in the SKILL.
When it comes to using SKILL files in general, I am not against it. My point was that on your PR you seem to implement skills that are only used by one agent or one command. Unless you intend to use the SKILL separately from the command itself, I am not sure it is needed. I feel like having too many option might also make the workflow more confusing.

@pedrosimao

Copy link
Copy Markdown
Author

@gotalab I have just implemented the changes you requested. I am open to do further improvement if you want.

@pedrosimao

Copy link
Copy Markdown
Author

@gotalab a small note on the SKILL discussion. I recently realized that fro Claude Code, skills will replace commands. Meaning commands will no longer be needed. So, I think the commands MD files could simply be deleted once SKILLs are in place.
I am not sure about other platforms like Opencode and Codex though. Hard to keep up with so many changes in these CLIs.

@hemato

hemato commented Apr 13, 2026

Copy link
Copy Markdown

Hi is this avaible ?

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.

3 participants