MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / classifyForPrompt

Method classifyForPrompt

src/agent/loop.ts:2545–2572  ·  view source on GitHub ↗

* Classify the user's request for the purpose of system-prompt addendum. * Different from classifyTask (which is for router model selection); this * picks ONE of refactor/debug/feature/review/explain/general based on the * user's verbs and structure.

(initial: Message[])

Source from the content-addressed store, hash-verified

2543 `(This refusal came from a user-configured lifecycle hook, not the model. ` +
2544 `Adapt your approach — do NOT retry the same call.)`,
2545 isError: true,
2546 uiEvents,
2547 };
2548 }
2549 // Non-blocking outputs are surfaced as informational UI events
2550 for (const out of hookResult.outputs) {
2551 uiEvents.push({ type: 'log', data: { source: 'PreToolUse', message: out } } as any);
2552 }
2553 }
2554
2555 try {
2556 // ─── Within-turn read-only cache: short-circuit if we have the result ───
2557 const tool = this.registry.get(tc.function.name);
2558 if (this.toolCache && tool && tool.isReadOnly) {
2559 const cached = this.toolCache.get(tc.function.name, args);
2560 if (cached) {
2561 logger.info('Tool result cache hit', { tool: tc.function.name });
2562 return { content: cached, isError: false, uiEvents };
2563 }
2564 }
2565
2566 // ─── Pre-flight architecture gate (model-agnostic discipline floor) ───
2567 // On a build/refactor task, require a plan BEFORE the first code change. Soft +
2568 // one-shot: if the model hasn't planned, return a corrective result it can adapt to;
2569 // we then let it proceed (never blocks twice → can't lock the agent). A planning call
2570 // (present_plan / todo_write / writing a DESIGN doc) satisfies the gate instead of tripping it.
2571 if (this.planGateComplex && tool && !tool.isReadOnly) {
2572 if (isPlanningToolCall(tc.function.name, args)) {
2573 this.planGateSatisfied = true; // good — the model is planning; let it through
2574 } else if (tc.function.name.startsWith('artifact_')) {
2575 // Artifact tools produce a standalone deliverable (a page/component the user keeps),

Callers 1

buildInitialMessagesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected