Prevent concurrent agent instances from interfering with each other by using isolated session folders.
.tmp/sessions/{session-id}/{task-category}/{task-name}-context.md
{timestamp}-{random-4-chars}
Example: 20250118-143022-a4f2
Each session has a manifest file tracking all context files:
Location: .tmp/sessions/{session-id}/.manifest.json
Structure:
{
"session_id": "20250118-143022-a4f2",
"created_at": "2025-01-18T14:30:22Z",
"last_activity": "2025-01-18T14:35:10Z",
"context_files": {
"features/user-auth-context.md": {
"created": "2025-01-18T14:30:22Z",
"for": "@subagents/core/task-manager",
"keywords": ["user-auth", "authentication", "features"]
},
"tasks/user-auth-tasks.md": {
"created": "2025-01-18T14:32:15Z",
"for": "@subagents/core/task-manager",
"keywords": ["user-auth", "tasks", "breakdown"]
},
"documentation/api-docs-context.md": {
"created": "2025-01-18T14:35:10Z",
"for": "@subagents/core/documentation",
"keywords": ["api", "documentation"]
}
},
"context_index": {
"user-auth": [
"features/user-auth-context.md",
"tasks/user-auth-tasks.md"
],
"api": [
"documentation/api-docs-context.md"
]
}
}
Only create context files when ALL of these apply:
.tmp/sessions/{session-id}/{task-category}/{task-name}-context.md
features/ - Feature development contextdocumentation/ - Documentation taskscode/ - Code-related tasksrefactoring/ - Refactoring taskstesting/ - Testing taskstasks/ - Task breakdowns created by task-managergeneral/ - General tasks that don't fit other categories.tmp/sessions/20250118-143022-a4f2/features/user-auth-context.md
.tmp/sessions/20250118-143022-a4f2/documentation/api-docs-context.md
.tmp/sessions/20250118-150000-b7k9/code/database-refactor-context.md
.tmp/sessions/20250118-151500-c3x8/testing/integration-tests-context.md
# Context: {Task Name}
Session: {session-id}
## Request Summary
[Brief description of what needs to be done]
## Background
[Relevant context and information]
## Expected Output
[What the subagent should produce]
## Constraints
[Any limitations or requirements]
last_activity timestamp.tmp/sessions/{session-id}/last_activity timestamp in manifestUsers can safely delete:
.tmp/ folder anytimelast_activity timestamp)✅ Each agent instance has unique session ID ✅ Context files are isolated per session ✅ Manifest tracks only files created by this session ✅ Cleanup only affects current session's files ✅ No risk of deleting another instance's context
last_activity on each operationAllow subagents to discover and load relevant context files created earlier in the session.
1. Context File Creation When creating a context file, add metadata to manifest:
"context_files": {
"features/user-auth-context.md": {
"created": "2025-01-18T14:30:22Z",
"for": "@subagents/core/task-manager",
"keywords": ["user-auth", "authentication", "features"]
}
}
2. Context Indexing Manifest maintains keyword index for fast lookup:
"context_index": {
"user-auth": [
"features/user-auth-context.md",
"tasks/user-auth-tasks.md"
]
}
3. Context Discovery When delegating to subagent:
4. Delegation Pattern
Delegating to @subagents/code/coder-agent:
"Implement user authentication login component.
Related context available at:
- .tmp/sessions/20250118-143022-a4f2/features/user-auth-context.md
- .tmp/sessions/20250118-143022-a4f2/tasks/user-auth-tasks.md
Read these files for full context on requirements and task breakdown."
1. User: "Build user authentication system"
→ OpenAgent creates: features/user-auth-context.md
→ Delegates to @task-manager
2. Task-manager creates: tasks/user-auth-tasks.md
→ Both files tracked in manifest with keyword "user-auth"
3. User: "Implement the login component"
→ OpenAgent searches manifest for "user-auth" context
→ Finds both context files
→ Delegates to @coder-agent with references to both files
→ Coder-agent reads files to understand full context
.tmp/sessions/?.tmp/ convention (commonly ignored)sessions/ subfolder makes purpose clear.)# Agent Instance 1 starts
Session ID: 20250118-143022-a4f2
Creates: .tmp/sessions/20250118-143022-a4f2/features/user-auth-context.md
# Agent Instance 2 starts (concurrent)
Session ID: 20250118-143030-b7k9
Creates: .tmp/sessions/20250118-143030-b7k9/features/payment-context.md
# Both agents work independently without conflicts
# Agent Instance 1 completes
Deletes: .tmp/sessions/20250118-143022-a4f2/ (entire folder)
# Agent Instance 2 continues unaffected
Still has: .tmp/sessions/20250118-143030-b7k9/