Skip to content

[contexto]: Prototype Phase 2 — sub-agent context infra on OpenClaw #138

Description

@sm86

Background

Phase 2 of the agent handoff roadmap is sub-agents: distributing structured context horizontally so each sub-agent receives only what it needs and composes results back without losing constraints.

OpenClaw's plugin SDK already exposes the surface for this (prepareSubagentSpawn, onSubagentEnded on ContextEngine). Today both are no-ops in AbstractContextEngine (packages/contexto/src/engine/base.ts).

Goal

A design plan + working PoC that turns those hooks into real behavior end-to-end against an OpenClaw sub-agent flow.

Design plan should cover

  • Context packet shape — what slice of mindmap state travels with the spawn (filtered episodes? branch subset? path ancestors?).
  • Scoping — how to constrain a sub-agent to its task without leaking unrelated branches.
  • Return composition — how sub-agent outputs (and any new constraints surfaced during its run) get folded back into the parent mindmap on onSubagentEnded.
  • Traceability — how a parent retrieval can later explain "this came from sub-agent X working on Y".
  • Backend contract — what (if any) new endpoints the hosted backend needs (e.g. mindmap.subgraph, mindmap.merge).

PoC scope

  • Implement prepareSubagentSpawn + onSubagentEnded in DefaultContextEngine (sliding-window can come later).
  • One concrete OpenClaw demo: parent agent decomposes a task, spawns one sub-agent with a scoped context packet, sub-agent's episode is ingested under a traceable parent link, parent retrieval can surface it.
  • Keep changes additive — don't break existing single-agent flows.

Acceptance criteria

  • Design doc committed under docs/explorations/ (or similar) and linked from this issue
  • PoC branch with the demo flow runnable via a documented script
  • Notes on what didn't work / what the backend needs before this can ship for real

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions