LLM generates invalid node type 'func' instead of 'function'
Problem
The dashboard fails to load knowledge graphs with the error:
Invalid option: expected one of "file"|"function"|"class"|"module"|"concept"
When running /understand --full on a FastAPI server codebase, the LLM wrote "type": "func" instead of "type": "function" for 104 out of 267 nodes — every single function node in the graph.
Actual generated JSON
Here's what the LLM produced (actual output from the intermediate batch files):
{
"id": "func:ai/emergency_inference.py:is_emergency",
"type": "func",
"name": "is_emergency",
"filePath": "ai/emergency_inference.py",
"summary": "Async Langfuse-traced function that classifies a user message as an emergency...",
"tags": ["async", "langfuse-observed", "emergency-classification", "openai"],
"complexity": "moderate"
}
{
"id": "func:ai/intent_recognition_inference.py:classify_intent",
"type": "func",
"name": "classify_intent",
"filePath": "ai/intent_recognition_inference.py",
"summary": "Async Langfuse-traced function that classifies a WhatsApp user message into a prioritised intent...",
"tags": ["intent-classification", "langfuse-observed", "openai"],
"complexity": "moderate"
}
The "type": "func" is consistent across all 104 function nodes — it's not random, the LLM is systematically abbreviating.
Root cause
The file-analyzer-prompt.md uses func: as the node ID prefix convention:
| Function | `func:<relative-path>:<function-name>` | `func:src/utils.ts:formatDate` |
And the scope restriction says:
Scope restriction: Only produce
file:,func:, andclass:nodes.
The LLM sees func used throughout the prompt context (in IDs, in scope text) and writes "type": "func" in the JSON, even though the example shows "type": "function". The ID prefix func: and the type value "function" are inconsistent, and the LLM normalizes to the shorter form it sees more frequently.
Proposed fix
Option A (simplest): Rename the ID prefix from func: to function: everywhere — prompts, graph-builder.ts, and tests. This eliminates the ambiguity so the LLM sees function: in IDs and "function" in the type field consistently.
Option B (defense in depth): Add a normalization step in schema.ts that maps common LLM abbreviations before validation:
const NODE_TYPE_ALIASES: Record<string, string> = {
func: "function",
fn: "function",
method: "function",
interface: "class",
struct: "class",
};
Both can be combined — fix the prompt ambiguity and add runtime normalization as a safety net.
Impact
Any codebase with function nodes can hit this. Python-heavy repos with many standalone functions are most affected since they produce more func: ID-prefixed nodes.
Hi, thanks for the feedback. Option B seems more useful and scable in the future.