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

Method constructor

src/agent/loop.ts:176–212  ·  view source on GitHub ↗
(opts: {
    router: ModelRouter;
    registry: ToolRegistry;
    permissions: PermissionEngine;
    config: QodexConfig;
    cwd: string;
  })

Source from the content-addressed store, hash-verified

174 private lastModelSource = '';
175 private lastEffectiveCtxWindow = 0;
176 /** Calls auto-offloaded to the cheap model this session (offload.enabled) — forwarded on
177 * budget_update so the status bar / dashboard can show the policy actually firing. */
178 private offloadedCalls = 0;
179 private totalToolCalls = 0; // running count of executed tool calls (skill-capture eligibility)
180 /** ORDERED tool names as executed (unlike sessionToolNames, which is a distinct set) —
181 * feeds skill distillation's step outline. Capped so a marathon session stays bounded. */
182 private sessionToolSequence: string[] = [];
183 private static readonly TOOL_SEQUENCE_CAP = 2000;
184 private currentTaskKey = ''; // stable key for THIS run's task (failure-driven learning)
185 // Ground-truth verification ledger: every checker QodeX actually ran this run + its result.
186 // Feeds the trust receipt — uncounterfeitable because the WORKER measured it, not the model.
187 private verifyLedger: Array<{ command: string; passed: boolean }> = [];
188 private styleBlock: string | null = null; // inferred code-style block, computed once per session
189 /** Per-session operational insights (tokens / tools / latency). In-memory; persisted to the session row. */
190 private insightsBySession = new Map<string, SessionInsights>();
191
192 /** Record a tool failure to episodic memory (best-effort, opt-in). Only fires when
193 * failure-driven learning is enabled; the pattern miner later decides what's worth
194 * learning. Fire-and-forget — never blocks or throws into the loop. */
195 private recordToolFailure(tool: string, content: string): void {
196 if (!(this.config as any).learning?.failureLessons?.enabled) return;
197 if (!this.currentTaskKey) return;
198 void (async () => {
199 try {
200 const { recordFailure, normalizeFailureSignature } = await import('../skills/learning/failures.js');
201 await recordFailure({
202 task: this.currentTaskKey,
203 tool,
204 signature: normalizeFailureSignature(tool, content),
205 sample: (content || '').replace(/\s+/g, ' ').trim().slice(0, 160),
206 });
207 } catch { /* best-effort */ }
208 })();
209 }
210 /** Auto tool profile: null = not yet derived this session; then a ratcheting list. */
211 private autoDisabledTools: string[] | null = null;
212 /** Live context windows read from LM Studio's native API, fetched once per session. */
213 private liveCtxWindows: Record<string, number> | null = null;
214 private liveCtxFetched = false;
215 /** Adaptive thinking: force a THINK pass on the next iteration (steer/verify-repair). */

Callers

nothing calls this directly

Calls 1

efficiencyDefaultsFunction · 0.85

Tested by

no test coverage detected