davila7/claude-code-templates · warning
Agent not found
Error message
Agent not found
What it means
HTTP 404 from the teammate detail route when the session exists but session.agents[req.params.agentId] is undefined — the agentId doesn't match any agent key in that session.
Source
Thrown at cli-tool/src/teams-dashboard.js:756
if (!session) return res.status(404).json({ error: 'Session not found' });
res.json({
tasks: session.tasks,
count: session.tasks.length
});
} catch (error) {
res.status(500).json({ error: 'Failed to load tasks' });
}
});
// Single teammate detail
this.app.get('/api/sessions/:id/teammates/:agentId', async (req, res) => {
try {
const session = await this.parseFullSession(req.params.id);
if (!session) return res.status(404).json({ error: 'Session not found' });
const agent = session.agents[req.params.agentId];
if (!agent) return res.status(404).json({ error: 'Agent not found' });
// Get agent-specific events
const agentEvents = session.events
.filter(e => e.agentId === req.params.agentId)
.slice(0, 100);
res.json({
...agent,
recentEvents: agentEvents
});
} catch (error) {
res.status(500).json({ error: 'Failed to load teammate' });
}
});
// Main route
this.app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'teams-dashboard-web', 'index.html'));View on GitHub (pinned to a0851ed10c)
Solutions
- Fetch /api/sessions/:id and use an exact key from session.agents
- Check the agentId format (key, not display name)
- Refresh the UI's agent list for the current session
Defensive patterns
Strategy: validation
Validate before calling
const detail = await fetch(`/api/sessions/${id}`).then(r => r.json());
if (!detail.agents?.[agentId]) throw new Error('unknown agent'); Type guard
const isKnownAgent = (detail, agentId) => Boolean(detail?.agents?.[agentId]);
Prevention
- Use agent id keys from session.agents, not display names
- Refresh the agent list when the session re-parses
When it happens
Trigger: GET /api/sessions/:id/teammates/wrong-agent; using an agent name instead of the agentId key; agent list from a different session.
Common situations: UI passing display names instead of agent ids; stale agent list after session re-parse; case/format mismatch in the id.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/61e7573b3700568a.
Report an issue: GitHub.