feat: agent hierarchy — templates, org chart, role@project naming - #102
Merged
Conversation
aterrylu
marked this pull request as ready for review
April 2, 2026 11:12
Add agent template system and hierarchy management to autonomOS. Templates (blueprints for agent roles): - Individual JSON files at ~/.autonomos/templates/*.json - create_template / list_templates MCP tools + REST API - Path traversal protection on template names - Marketplace-ready: drop a file to install, delete to uninstall Org chart (hierarchy via persisted session metadata): - template, manager, project fields on PersistedSession - set_manager / get_org_chart MCP tools + REST API - Hierarchy derived at query time from manager references - Agents or humans configure relationships after spawning Base context rewrite: - Identity, communication, environment, lifecycle sections - Tool list interpolated from MCP_INSTRUCTIONS (single source of truth) Design decisions (validated by research): - No per-agent config folders — sessions ARE agents - Templates define types, not instances (matches Overstory/Citadel pattern) - Hierarchy emerges organically, not deployed rigidly - Agents own vertical features, not horizontal layers Research: docs/research/singleton-agent-pattern.md, docs/research/persistent-agent-identity.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
aterrylu
force-pushed
the
terry/agent-hierarchy
branch
from
April 2, 2026 11:13
1075532 to
d967625
Compare
nox-0x
reviewed
Apr 2, 2026
|
|
||
| Messages are asynchronous — the recipient may be busy or idle. Do not block \ | ||
| waiting for a response. Continue your work and handle replies when they arrive. | ||
|
|
Collaborator
There was a problem hiding this comment.
🟡 Warning
Problem: ${MCP_INSTRUCTIONS} in the BASE_CONTEXT template literal coerces the array to a string via .toString(), which joins elements with commas — not newlines.
Why it matters: Every spawned agent gets a system prompt where the tool list reads as one run-on comma-separated line: "You are running inside autonomOS — an agent orchestration platform.,,Available tools:,- send(to, message): Send messages via URI...,". The tool documentation is still technically present, but it is much harder for the model to parse as structured instructions.
Suggested fix:
// Join with newlines before interpolating
${MCP_INSTRUCTIONS.join("\n")}Or define the constant as a pre-joined string:
// In mcp/tools.ts
export const MCP_INSTRUCTIONS_TEXT = MCP_INSTRUCTIONS.join("\n");
// In sessions.ts
${MCP_INSTRUCTIONS_TEXT}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.autonomos/templates/*.jsonfor defining agent roles (system prompt, capabilities, model). Created viacreate_templateMCP tool or by dropping a JSON file. Marketplace-ready individual file model.set_managerandget_org_chartMCP tools let agents or humans configure relationships at runtime. Tree derived from manager references.MCP_INSTRUCTIONS(single source of truth).Architecture decisions
graph TD T[~/.autonomos/templates/*.json] -->|blueprint| S[create_agent] S -->|spawns| P[sessions.json] P -->|metadata| O[get_org_chart] M[set_manager] -->|updates| P style T fill:#2d5a27 style P fill:#1a3a5c style O fill:#5a2d27deploy_orgtool. CEO agent or human usesset_managerafter spawning.New MCP tools
create_templatelist_templatesset_managerget_org_chartNew REST endpoints
/api/templates/api/templates/api/org/api/org/managerFiles changed
agent.ts,provider.ts,index.tstemplates.ts(new)orgChart.ts(new),hierarchy.ts(new)tools.ts,mcp.tspersisted.ts,sessions.ts,routes/sessions.tsindex.ts,dist.mjsmcp-tools.test.tsCLAUDE.md,RESEARCH.mdsingleton-agent-pattern.md,persistent-agent-identity.mdTest plan
list_agents()— shows all active agentsget_org_chart()— shows hierarchy tree with manager relationshipslist_templates()— empty initially, populated after createcreate_template()— creates template file on diskset_manager()— updates hierarchy, reflected in org chartsend()— inter-agent messaging works with hierarchy🤖 Generated with Claude Code