Skip to content

Generate a Node.js adapter with improve init --language node - #353

Merged
dipeshbabu merged 1 commit into
mainfrom
feat/node-guided-init
Nov 19, 2026
Merged

dipeshbabu merged 1 commit into
mainfrom
feat/node-guided-init

Conversation

@dipeshbabu

Copy link
Copy Markdown
Owner

The guided workflow could only connect Python callables, so agents using the npm TypeScript SDK had no way into `improve capture/start/finish/compare`.

`agentloop improve init --language node [--agent ./src/agent.mjs:answer]` writes:

  • `agentloop_runner.mjs`: imports the export from a relative `.mjs/.js/.cjs` module (resolved from the runner), calls it as `answer(input, trace)` with an SDK `AgentTrace`, records the output with `setOutput` (finite JSON), writes a failed trace when the agent throws, `--check`/`--debug` like the Python adapter;
  • without `--agent`: `agentloop_example.mjs` (repeated traced lookup) and a `package.json` depending on `agentloop-profiler`;
  • shared task data, project config and a Node-specific `AGENTLOOP.md`.

Targets are validated (relative path inside the project, JS identifier export); Python output is unchanged.

Verification

  • `scripts/smoke_node_guided.py`: full guided flow (init → npm install SDK → check → capture → start → documented change → capture → finish passes), a throwing agent recorded as failed attempts, and `--check` reporting a missing export. Added to the TypeScript CI job against the packed SDK (Node 22 and 24); passes locally with the built dir, a packed tgz and the published npm 0.1.2.
  • Unit tests for generated files, existing-project mode, target validation and CLI output.
  • Docs: GUIDED_OPTIMIZATION "Connect an existing Node.js agent", README, changelog.

🤖 Generated with Claude Code

The guided workflow could only connect Python callables, so agents using
the npm TypeScript SDK had no way into capture, start and finish. init
--language node writes agentloop_runner.mjs, which imports a relative
module export, calls it as answer(input, trace) with an SDK trace and
writes a failed trace when it throws; without --agent it adds an offline
example and package.json. A smoke script runs the full guided workflow,
a failing agent and a missing export against the packed SDK in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown

AgentLoop replay self-test

This required repository check evaluates generated synthetic demo traces. It tests the replay and CI machinery; it does not show that this PR improves application performance.

AgentLoop CI Report

  • Status: passed
  • Replay: Replay passed: latency improvement 69.67%, cost improvement 78.82%, retry delta -1.
  • Merge recommendation: synthetic self-test only; assess application traces before merge
  • Findings: 1 total, 0 high severity, 1 patchable

Performance Gates

Gate Status Detail
latency_regression pass 0.00% regression <= 0.00% allowed
cost_regression pass 0.00% regression <= 0.00% allowed
latency_improvement pass 69.67% improvement >= 20.00% required
cost_improvement pass 78.82% improvement >= 5.00% required
retry_non_increase pass 0 candidate retries <= 1 baseline retries

Trace inputs

This comparison includes synthetic data. It does not establish application performance gains from a pull request.

Side Run ID Path Synthetic marker Source
baseline run_1ab84ec0c6c348da runs/research_agent_baseline.json yes agentloop_demo
candidate run_d4a958c84b1e4cf1 runs/research_agent_optimized.json yes agentloop_demo

Metric Impact

Metric Impact
Latency improvement 69.67%
Cost improvement 78.82%
Retry delta -1
Candidate schema validity not provided
Candidate quality score not provided

Top Findings

Finding Severity Type Rewrite
al_cache_context_f8219067165c: Cache repeated prompt/context prefix medium cache_context Move stable instructions into cached prefixes, summaries, or framework-level memory instead of resending full text.

@dipeshbabu
dipeshbabu merged commit 7f4392f into main Nov 19, 2026
25 checks passed
@dipeshbabu
dipeshbabu deleted the feat/node-guided-init branch November 19, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant