🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(integration): TokenOptimizer.optimizedEdit uses the real agent-booster API (#4311) (#4315)
rUvf5f2e40c318c
diff --git a/scripts/ci-test-baseline.txt b/scripts/ci-test-baseline.txtindex 8fe284ff18..a80ce5ede8 100644--- a/scripts/ci-test-baseline.txt+++ b/scripts/ci-test-baseline.txt@@ -99,7 +99,6 @@ v3/@claude-flow/hooks/__tests__/channel-guard-worker.test.tsv3/@claude-flow/hooks/__tests__/workers.test.tsv3/@claude-flow/hooks/src/__tests__/guidance-provider.test.tsv3/@claude-flow/hooks/src/__tests__/reasoningbank.test.ts-v3/@claude-flow/integration/src/__tests__/token-optimizer.test.tsv3/@claude-flow/memory/src/agentdb-backend.test.tsv3/@claude-flow/memory/src/agentdb-retrieval-guard.test.tsv3/@claude-flow/memory/src/consolidator-embedding-benchmark.test.tsdiff --git a/v3/@claude-flow/integration/src/token-optimizer.ts b/v3/@claude-flow/integration/src/token-optimizer.tsindex c998317cdf..d8cccfcc9e 100644--- a/v3/@claude-flow/integration/src/token-optimizer.ts+++ b/v3/@claude-flow/integration/src/token-optimizer.ts@@ -90,8 +90,12 @@ export class TokenOptimizer extends EventEmitter {const ab = await safeImport<any>('agentic-flow/agent-booster');if (ab) {- // Agent booster may export different API- this.agentBooster = ab.agentBooster || ab.AgentBooster || ab;+ // The real package exports a `getAgentBooster()` factory returning an+ // instance whose prototype has `apply`/`applyBatch` (#4311) — calling+ // `.apply` on the un-instantiated export (`ab.AgentBooster`, a class)+ // would silently resolve to `Function.prototype.apply` instead.+ this.agentBooster =+ typeof ab.getAgentBooster === 'function' ? ab.getAgentBooster() : ab.agentBooster || ab.AgentBooster || ab;}this.agenticFlowAvailable = rb !== null || ab !== null;@@ -200,23 +204,36 @@ export class TokenOptimizer extends EventEmitter {};}- const result = await this.agentBooster.editCode({- filePath,- oldContent,- newContent,+ // agentic-flow/agent-booster's real API is `apply({ code, edit, language,+ // filePath? })` → `{ output, success, latency, strategy, ... }` — there is+ // no `editCode` method and no `speedupFactor`/`executionTimeMs`/`method`+ // on its result (#4311).+ const result = await this.agentBooster.apply({+ code: oldContent,+ edit: newContent,language,+ filePath,});+ // A 'fallback'/'error_avoided' strategy means the booster declined to+ // optimize this edit, not that it failed outright.+ const method: EditOptimization['method'] =+ result.success && result.strategy !== 'fallback' && result.strategy !== 'error_avoided'+ ? 'agent-booster'+ : 'traditional';+// Track optimized edits (no fabricated token savings — actual savings// come from fewer retries, which we can't measure here)- if (result.method === 'agent-booster') {+ if (method === 'agent-booster') {this.stats.editsOptimized++;}return {- speedupFactor: result.speedupFactor,- executionMs: result.executionTimeMs,- method: result.method,+ // No real speedup measurement is available from this API either;+ // keep the same "no claim" value the no-booster fallback above uses.+ speedupFactor: 1,+ executionMs: result.latency,+ method,};}