Skip to content

Add persistent agent state and reputation-aware service selection - #464

Open
vaishnavidesai09 wants to merge 4 commits into
Stellar-Ecosystem:mainfrom
vaishnavidesai09:agent-persistent-state
Open

Add persistent agent state and reputation-aware service selection#464
vaishnavidesai09 wants to merge 4 commits into
Stellar-Ecosystem:mainfrom
vaishnavidesai09:agent-persistent-state

Conversation

@vaishnavidesai09

@vaishnavidesai09 vaishnavidesai09 commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • add persistent agent state storage
  • track provider success/failure history
  • implement reputation-aware weighted service selection
  • filter providers using a configurable minimum reputation threshold
  • retry with alternative providers after failures
  • submit positive and negative reputation votes based on task outcome
  • document the new persistent state behavior
  • add tests covering persistence, retries, reputation thresholds, and voting

Testing

npm test

All 28 tests pass.

Closes #364

Summary by CodeRabbit

  • New Features
    • Added optional persistent agent state for score history, provider performance, and cumulative spend.
    • Service selection now accounts for payment history and provider reliability.
    • Providers with repeated payment failures are excluded from task eligibility.
  • Reliability
    • Missing or corrupted state automatically recovers.
    • TTL warnings gracefully handle unavailable ledger information.
  • Bug Fixes
    • Registration dates now display “Ledger unavailable” when unavailable.
  • Documentation
    • Added guidance for persistent agent state.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The agent now persists score history, provider outcomes, and cumulative spend in agent-state.json. Registry responses retain TTL warning handling, and the frontend displays a fallback when registration data is missing.

Changes

Persistent agent state

Layer / File(s) Summary
State storage contract
agent/state.js
Adds JSON state reading, corruption recovery, lazy per-agent initialization, and formatted persistence.
Agent state loading and scoring
agent/agent.js
Loads state during registration and task startup, then records timestamped score history.
History-aware service execution
agent/agent.js, agent/agent.test.js, README.md
Uses provider failures for eligibility and weighting, records payment outcomes and cumulative spend, initializes test state, and documents persistence.

Registry TTL annotation

Layer / File(s) Summary
TTL warning response handling
backend/src/routes/registry.js, backend/src/routes/registry.test.js
Adds and uses TTL warning annotation logic, preserves graceful degradation, and logs selected test responses.

Nullable service display data

Layer / File(s) Summary
Ledger fallback and agent fixtures
frontend/components/ServiceCard.tsx, frontend/lib/sort.test.ts
Displays Ledger unavailable when registration data is absent and adds a reusable sorting-test fixture helper.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: naninu123

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Backend registry changes, response logging, ServiceCard formatting, and sorting helpers are unrelated to issue #364. Remove unrelated backend, frontend, and test changes, or link them to separate issues.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the persistent state and reputation-aware service selection changes.
Linked Issues check ✅ Passed The changes persist agent state, use provider failure history, document the store location, and handle corrupt files gracefully for issue #364.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@vaishnavidesai09 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vaishnavidesai09

Copy link
Copy Markdown
Author

Hey @ritik4ever Kindly review pr

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent/agent.js`:
- Around line 408-420: Update the settled endpoint-error branch near
submitReputation to add the paid amount to cumulativeSpend before retrying
another provider. Reuse the existing cumulative-spend update mechanism and
selected.price_usdc value, while preserving the current failure tracking and
state persistence behavior.

In `@agent/state.js`:
- Around line 15-20: Update the state-loading logic around the JSON.parse flow
to validate that the parsed value is a non-null object, then normalize each
agent entry so required nested fields such as providerHistory are initialized to
the shapes expected by agent/agent.js, including an array for scoreHistory.
Treat invalid or schema-incompatible state like corrupt input by returning a
safe normalized empty/default state, while preserving valid entries and the
existing warning behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 52140ede-94bf-4697-a1bb-5b47dd312ee9

📥 Commits

Reviewing files that changed from the base of the PR and between a3fd824 and d789110.

📒 Files selected for processing (4)
  • README.md
  • agent/agent.js
  • agent/agent.test.js
  • agent/state.js

Comment thread agent/agent.js
Comment on lines 408 to +420
if (scoringEnabled) await recordOutcome(selected.price_usdc, false, selected.id);
// Payment settled but service returned bad data — penalise service reputation.
await submitReputation(selected.id, false);
if (agentState?.providerHistory) {
const history = agentState.providerHistory[selected.id] ?? {
successes: 0,
failures: 0,
};

history.failures++;
agentState.providerHistory[selected.id] = history;
saveAgentState(AGENT_ADDRESS, agentState);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Count settled endpoint-error payments in cumulative spend.

This branch says the payment has settled, but only increments failures. Retrying another provider then leaves cumulativeSpend lower than the amount actually paid.

Proposed fix
       history.failures++;
       agentState.providerHistory[selected.id] = history;
+      agentState.cumulativeSpend += parseFloat(selected.price_usdc);
       saveAgentState(AGENT_ADDRESS, agentState);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (scoringEnabled) await recordOutcome(selected.price_usdc, false, selected.id);
// Payment settled but service returned bad data — penalise service reputation.
await submitReputation(selected.id, false);
if (agentState?.providerHistory) {
const history = agentState.providerHistory[selected.id] ?? {
successes: 0,
failures: 0,
};
history.failures++;
agentState.providerHistory[selected.id] = history;
saveAgentState(AGENT_ADDRESS, agentState);
}
if (scoringEnabled) await recordOutcome(selected.price_usdc, false, selected.id);
// Payment settled but service returned bad data — penalise service reputation.
await submitReputation(selected.id, false);
if (agentState?.providerHistory) {
const history = agentState.providerHistory[selected.id] ?? {
successes: 0,
failures: 0,
};
history.failures++;
agentState.providerHistory[selected.id] = history;
agentState.cumulativeSpend += parseFloat(selected.price_usdc);
saveAgentState(AGENT_ADDRESS, agentState);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent/agent.js` around lines 408 - 420, Update the settled endpoint-error
branch near submitReputation to add the paid amount to cumulativeSpend before
retrying another provider. Reuse the existing cumulative-spend update mechanism
and selected.price_usdc value, while preserving the current failure tracking and
state persistence behavior.

Comment thread agent/state.js
Comment on lines +15 to +20
try {
const raw = fs.readFileSync(STATE_FILE, "utf8");
return JSON.parse(raw);
} catch (err) {
console.warn("Ignoring corrupt state file:", err.message);
return {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Recover from schema-invalid state as well as invalid JSON.

null parses successfully but makes state[agentAddress] throw. Partial entries such as { "address": { "providerHistory": {} } } later make agent/agent.js attempt scoreHistory.push(...) on undefined. Validate the top-level object and normalize every agent entry before returning it.

Proposed fix
+function isRecord(value) {
+  return value !== null && typeof value === "object" && !Array.isArray(value);
+}
+
 function readState() {
   ...
-    return JSON.parse(raw);
+    const state = JSON.parse(raw);
+    if (!isRecord(state)) throw new Error("State must be an object");
+    return state;
   ...
 }

 export function getAgentState(agentAddress) {
   const state = readState();
-
-  if (!state[agentAddress]) {
+  const saved = state[agentAddress];
+  if (
+    !isRecord(saved) ||
+    !Array.isArray(saved.scoreHistory) ||
+    !isRecord(saved.providerHistory) ||
+    !Number.isFinite(saved.cumulativeSpend)
+  ) {
     state[agentAddress] = {
-      scoreHistory: [],
-      providerHistory: {},
-      cumulativeSpend: 0,
+      scoreHistory: Array.isArray(saved?.scoreHistory) ? saved.scoreHistory : [],
+      providerHistory: isRecord(saved?.providerHistory) ? saved.providerHistory : {},
+      cumulativeSpend: Number.isFinite(saved?.cumulativeSpend) ? saved.cumulativeSpend : 0,
     };
     writeState(state);
   }

Also applies to: 35-42

🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 15-15: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.readFileSync(STATE_FILE, "utf8")
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

(detect-non-literal-fs-filename)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent/state.js` around lines 15 - 20, Update the state-loading logic around
the JSON.parse flow to validate that the parsed value is a non-null object, then
normalize each agent entry so required nested fields such as providerHistory are
initialized to the shapes expected by agent/agent.js, including an array for
scoreHistory. Treat invalid or schema-incompatible state like corrupt input by
returning a safe normalized empty/default state, while preserving valid entries
and the existing warning behavior.

@ritik4ever

Copy link
Copy Markdown
Collaborator

@vaishnavidesai09 please fix ci

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
backend/src/routes/registry.test.js (1)

88-89: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove temporary console logging from tests.

These console.log calls print response details during normal test runs, polluting CI output. Remove them after debugging.

Also applies to: 932-933

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/routes/registry.test.js` around lines 88 - 89, Remove the
temporary console.log calls for response status and body from the affected test
cases in the registry tests, including both referenced locations, while leaving
the test assertions and behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/routes/registry.js`:
- Around line 64-78: Update the comment above annotateTtlWarning to state that
ttl_warning:true is appended when the estimated remaining TTL is at or below
SERVICE_TTL_WARNING_LEDGERS, reflecting the inclusive >= predicate; keep the
unavailable-currentLedger behavior unchanged.

In `@frontend/lib/sort.test.ts`:
- Around line 20-29: Update the makeAgent fixture to match the AgentEntry type
exactly: remove the unsupported endpoint property and add required description,
owner, payment-total, last_active, active, flagged, and flag_reason fields with
appropriate test defaults, while preserving the existing overrides behavior.

---

Nitpick comments:
In `@backend/src/routes/registry.test.js`:
- Around line 88-89: Remove the temporary console.log calls for response status
and body from the affected test cases in the registry tests, including both
referenced locations, while leaving the test assertions and behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 44317052-ffe7-4d3e-bde3-61804bb2f64b

📥 Commits

Reviewing files that changed from the base of the PR and between d789110 and 2943659.

⛔ Files ignored due to path filters (2)
  • frontend/package-lock.json is excluded by !**/package-lock.json
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • backend/src/routes/registry.js
  • backend/src/routes/registry.test.js
  • frontend/components/ServiceCard.tsx
  • frontend/lib/sort.test.ts

Comment on lines +64 to +78
// Appends ttl_warning:true when the entry's estimated remaining TTL falls
// below SERVICE_TTL_WARNING_LEDGERS. Omits the field entirely when currentLedger
// is unavailable so callers can always treat absence as "no warning data".
function annotateTtlWarning(service, currentLedger) {
if (currentLedger == null) return service;

return {
...service,
ttl_warning:
currentLedger >=
service.registered_at +
SERVICE_MAX_TTL -
SERVICE_TTL_WARNING_LEDGERS,
};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the inclusive TTL threshold.

The predicate uses >=, so ttl_warning is emitted when the remaining TTL is at or below SERVICE_TTL_WARNING_LEDGERS, not only when it is below. Update the comment to match the tested behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/routes/registry.js` around lines 64 - 78, Update the comment
above annotateTtlWarning to state that ttl_warning:true is appended when the
estimated remaining TTL is at or below SERVICE_TTL_WARNING_LEDGERS, reflecting
the inclusive >= predicate; keep the unavailable-currentLedger behavior
unchanged.

Comment thread frontend/lib/sort.test.ts
Comment on lines +20 to +29
function makeAgent(overrides: Partial<AgentEntry> = {}): AgentEntry {
return {
address: 'GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFL',
name: 'Test Agent',
endpoint: 'https://example.com',
score: 0,
total_payments: '0',
registered_at: '0',
...overrides,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -A20 'interface AgentEntry' frontend/lib/types.ts
rg -n -A20 'function makeAgent' frontend/lib/sort.test.ts

Repository: Stellar-Ecosystem/lodestar

Length of output: 1398


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- frontend/tsconfig files ---\n'
fd 'tsconfig.*json$' frontend -x sh -c 'echo "### $1"; sed -n "1,220p" "$1"\'' sh {}

printf '\n--- package scripts and deps ---\n'
for f in package.json frontend/package.json; do
  [ -f "$f" ] && { echo "### $f"; cat "$f"; }
done

printf '\n--- sort.test.ts imports and relevant slice ---\n'
sed -n '1,220p' frontend/lib/sort.test.ts

printf '\n--- read-only shape verifier ---\n'
python3 - <<'PY'
import json, pathlib, re
types = pathlib.Path('frontend/lib/types.ts').read_text()
test = pathlib.Path('frontend/lib/sort.test.ts').read_text()

agent_iface = re.search(r'export interface\s+(\w+)\s*\{(?P<body>.*?)\n\}', types, re.S).groupdict()
assert agent_iface['name'] == 'AgentEntry'
fields = {m.group(1) for m in re.finditer(r'^\s*([A-Za-z_$][A-Za-z0-9_$]*)\s*:', agent_iface['body'], re.M)}
print('AgentEntry fields:', fields)

return_stmt = re.search(r'function\s+makeAgent\([^)]*\)\s*:\s*AgentEntry\s*\{[^}]*return\s*\{(?P<body>.*?)\n\s*\};'? , test, re.S)
if not return_stmt:
    return_stmt = re.search(r'function\s+makeAgent\([^)]*\)\s*:\s*AgentEntry\s*\{[^}]*return\s*\{(?P<body>.*?)\n\s*\}\s*\};'? , test, re.S)
fixture = {}
for m in re.finditer(r'^\s*([A-Za-z_$][A-Za-z0-9_$]*)\s*:', return_stmt.group('body'), re.M):
    fixture[m.group(1)] = True
print('fixture fields:', fixture)
print('missing required fields:', sorted(fields - set(fixture)))
print('extra fixture fields:', sorted(set(fixture) - fields))
print('has endpoint:', 'endpoint' in fixture)
PY

Repository: Stellar-Ecosystem/lodestar

Length of output: 255


Fix the AgentEntry fixture shape before merging.

makeAgent is declared to return AgentEntry, but it omits required fields (description, owner, payment totals, last_active, active, flagged, and flag_reason) and adds unsupported endpoint. This is a TypeScript compile-time failure.

Proposed fixture fix
 function makeAgent(overrides: Partial<AgentEntry> = {}): AgentEntry {
   return {
     address: 'GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFL',
     name: 'Test Agent',
-    endpoint: 'https://example.com',
+    description: 'Test agent',
+    owner: 'GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFL',
     score: 0,
     total_payments: '0',
+    successful_payments: '0',
+    failed_payments: '0',
+    total_volume_stroops: '0',
     registered_at: '0',
+    last_active: '0',
+    active: true,
+    flagged: false,
+    flag_reason: '',
     ...overrides,
   };
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function makeAgent(overrides: Partial<AgentEntry> = {}): AgentEntry {
return {
address: 'GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFL',
name: 'Test Agent',
endpoint: 'https://example.com',
score: 0,
total_payments: '0',
registered_at: '0',
...overrides,
};
function makeAgent(overrides: Partial<AgentEntry> = {}): AgentEntry {
return {
address: 'GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFL',
name: 'Test Agent',
description: 'Test agent',
owner: 'GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFL',
score: 0,
total_payments: '0',
successful_payments: '0',
failed_payments: '0',
total_volume_stroops: '0',
registered_at: '0',
last_active: '0',
active: true,
flagged: false,
flag_reason: '',
...overrides,
};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/lib/sort.test.ts` around lines 20 - 29, Update the makeAgent fixture
to match the AgentEntry type exactly: remove the unsupported endpoint property
and add required description, owner, payment-total, last_active, active,
flagged, and flag_reason fields with appropriate test defaults, while preserving
the existing overrides behavior.

@vaishnavidesai09

Copy link
Copy Markdown
Author

@ritik4ever please run tests to if ci passes

@ritik4ever

Copy link
Copy Markdown
Collaborator

Hi @vaishnavidesai09,

This PR could not be merged because it has merge conflicts with the target branch.

Please resolve the merge conflicts, push the updated changes, and the PR can be reviewed and merged.

Thank you!

@vaishnavidesai09

vaishnavidesai09 commented Jul 31, 2026

Copy link
Copy Markdown
Author

@ritik4ever done

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/src/routes/registry.js (1)

51-62: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Remove the duplicate annotateTtlWarning declaration.

backend/src/routes/registry.js is an ES module and declares annotateTtlWarning twice at the module top level, so the module fails to load. Keep one implementation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/routes/registry.js` around lines 51 - 62, Remove the duplicate
top-level annotateTtlWarning declaration in backend/src/routes/registry.js,
keeping a single implementation with the existing currentLedger and ttl_warning
behavior so the ES module loads successfully.
🧹 Nitpick comments (1)
agent/agent.js (1)

444-453: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract repeated provider-history update into a helper.

Three blocks (network failure, endpoint error, success) each read-or-initialize agentState.providerHistory[selected.id], mutate a counter, and call saveAgentState. Consolidate this into one helper, e.g. recordProviderOutcome(id, { success, spend }). This reduces duplication and removes the risk of one branch silently diverging from the others, as happened with the missing cumulativeSpend update in the endpoint-error branch.

Proposed refactor
+function recordProviderOutcome(id, { success, spendUsdc } = {}) {
+  if (!agentState?.providerHistory) return;
+  const history = agentState.providerHistory[id] ?? { successes: 0, failures: 0 };
+  if (success) {
+    history.successes++;
+    if (spendUsdc !== undefined) agentState.cumulativeSpend += parseFloat(spendUsdc);
+  } else {
+    history.failures++;
+  }
+  agentState.providerHistory[id] = history;
+  saveAgentState(AGENT_ADDRESS, agentState);
+}

Then call recordProviderOutcome(selected.id, { success: false }) and recordProviderOutcome(selected.id, { success: true, spendUsdc: selected.price_usdc }) at the respective sites.

Also applies to: 474-483, 508-521

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent/agent.js` around lines 444 - 453, Extract the repeated provider-history
read, counter update, cumulative-spend update, and save logic from the
network-failure, endpoint-error, and success branches into a shared
recordProviderOutcome helper. Have it accept the provider id and outcome data
such as success and spendUsdc, then replace each duplicated block with the
appropriate helper call while preserving existing failure, success, and spend
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@backend/src/routes/registry.js`:
- Around line 51-62: Remove the duplicate top-level annotateTtlWarning
declaration in backend/src/routes/registry.js, keeping a single implementation
with the existing currentLedger and ttl_warning behavior so the ES module loads
successfully.

---

Nitpick comments:
In `@agent/agent.js`:
- Around line 444-453: Extract the repeated provider-history read, counter
update, cumulative-spend update, and save logic from the network-failure,
endpoint-error, and success branches into a shared recordProviderOutcome helper.
Have it accept the provider id and outcome data such as success and spendUsdc,
then replace each duplicated block with the appropriate helper call while
preserving existing failure, success, and spend behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b99a6c6-683b-4c49-b822-ba1983e131f1

📥 Commits

Reviewing files that changed from the base of the PR and between 2943659 and 95add57.

📒 Files selected for processing (6)
  • README.md
  • agent/agent.js
  • agent/agent.test.js
  • backend/src/routes/registry.js
  • backend/src/routes/registry.test.js
  • frontend/components/ServiceCard.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • backend/src/routes/registry.test.js
  • agent/agent.test.js
  • frontend/components/ServiceCard.tsx

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.

Agent: no persistent state between runs

2 participants