Skip to main content

Sub-agents

Cognitive Modules supports inter-module calls, enabling complex task decomposition and composition.

@call Syntax

Use @call:module-name in MODULE.md to call other modules:

## Processing Flow

1. Analyze user requirements
2. Call UI spec generator:
@call:ui-spec-generator($ARGUMENTS)
3. Integrate results

Call Forms

SyntaxDescription
@call:module-namePass parent module input
@call:module-name($ARGUMENTS)Pass parent's $ARGUMENTS
@call:module-name(custom args)Pass custom arguments

context Configuration

fork (Isolated Execution)

---
name: parent-module
context: fork
---
  • Child module has independent context
  • Child results don't affect other children
  • Suitable for parallel execution of independent tasks

main (Shared Execution)

---
name: parent-module
context: main # Default
---
  • Child modules share parent context
  • Child results accessible to other children

Running

Sub-agent functionality is automatic. When module prompt contains @call: directive, runtime parses and executes:

# Run directly (@call handled automatically)
cog run parent-module --args "requirements"

Execution Flow

Parent Module Prompt

Parse @call:child-module

Execute child-module

Inject result [Result from @call:child-module]: {...}

Execute parent module

Final output

Example: product-analyzer

---
name: product-analyzer
version: 1.0.0
responsibility: Analyze product requirements and call UI spec generator
context: fork
---

# Product Analyzer

## Input

User product description: $ARGUMENTS

## Processing Flow

1. Requirements analysis
2. Call UI spec generator:
@call:ui-spec-generator($ARGUMENTS)
3. Integrate output

## Output

- analysis: Product analysis
- ui_spec: UI spec from @call
- recommendations: Recommendations

Run:

cog run product-analyzer --args "health product website" --pretty

Limitations

LimitationValue
Max call depth5 levels
Circular callsAuto-detected and blocked
Child validationSkip input validation, keep output validation