Skip to content

Fix agent service heartbeat JSON body - #4374

Merged
kojiwakayama merged 1 commit into
mainfrom
fix/agent-service-heartbeat-json-body
Sep 2, 2026
Merged

kojiwakayama merged 1 commit into
mainfrom
fix/agent-service-heartbeat-json-body

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • send the JSON object required by the strict control-plane heartbeat endpoint
  • lock the wire contract in the hosted registration lifecycle test

Why

The generic hosted agent replicas register successfully, then every heartbeat fails because the framework declares JSON without sending a body. The API deployment health gate correctly detects both registrations as stale.

Verification

  • red: focused registration test failed with an undefined heartbeat body
  • green: deno task test:file src/agent/service/registration.test.ts (27 steps)
  • deno task typecheck
  • focused deno fmt --check
  • focused deno lint
  • repository pre-push suite: 129 batches, 2,012 steps, plus serial and working-directory exclusion suites

This fixes the client at the owning boundary. It does not relax the API parser or deployment health gate.

Summary by CodeRabbit

  • Bug Fixes

    • Heartbeat requests now include a valid empty JSON payload, improving compatibility with the control plane.
  • Tests

    • Added validation to ensure heartbeat requests use the expected JSON body format.

The hosted agent registration client declared JSON but sent an empty request body, so strict control-plane parsing rejected every heartbeat and deployment health checks correctly failed. Send the minimal JSON object required by the existing endpoint contract and pin that behavior in the lifecycle test.

Constraint: The API heartbeat endpoint intentionally requires a JSON object.
Rejected: Relax the API parser | weakens a shared boundary and hides malformed clients.
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep heartbeat requests aligned with the strict control-plane schema.
Tested: Focused registration suite, framework typecheck, formatting, and lint.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review exact head 17f34e6

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-02T15:28:59.533036Z 17f34e6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gitar-bot

gitar-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Note

Automatic reviews are paused because your trial's included automatic processing has been used for this period. Upgrade now, or comment "Gitar review" to run a review anytime.
Learn more

Code Review ✅ Approved

Fixes the agent service heartbeat to send the required JSON object to the strict control-plane endpoint, resolving registration failures. Wire contract is locked in the hosted registration lifecycle test. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Important

Your trial ends in 6 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more.

Was this helpful? React with 👍 / 👎 | Gitar

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 288 2271 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@kwakayama kwakayama 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.

Review: 92/100 — correct, minimal fix with a regression test that pins the wire contract

Strengths

  • Root cause is real and precisely diagnosed: createHeaders() sets Content-Type: application/json on every request, but sendHeartbeatRequest sent no body, so a strict control-plane parser would reject the heartbeat. body: JSON.stringify({}) makes the request self-consistent with its own declared content type.
  • Fix is applied at the right boundary (the client), not by loosening server-side/API parsing — matches the PR description's stated intent and is the correct fix for a shared contract.
  • Test change is a good regression guard: it asserts calls[1].init.body === "{}" on the heartbeat call specifically (not the registration call), so it will actually catch a future regression rather than just re-asserting the currently-passing behavior.
  • Change is tightly scoped (+6/-0 across 2 files, 1 commit) — no unrelated churn, no API surface change.
  • PR description documents red/green verification, typecheck, fmt, lint, and the full pre-push suite, which is more rigor than this diff size would normally require.

Minor/optional (not blocking)

  • mergeable_state is currently blocked — worth confirming that's just outstanding required reviews/CI (which were still queued at review time) and not an actual merge conflict.
  • Very small nit, non-blocking: body: JSON.stringify({}) is a magic literal repeated implicitly against the registration path's JSON.stringify(buildRegistrationRequest(input)). A named constant (e.g. EMPTY_JSON_BODY = "{}") shared between the heartbeat call and its test assertion would make the "this must literally be {}" contract self-documenting, but this is style preference, not a defect.

This is a textbook small bugfix: clear root cause, minimal diff, and a test that would have failed before the fix and passes after. No functional, security, or design concerns.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 23aa878a-b6dd-40e2-9d1a-2ee1307e8576

📥 Commits

Reviewing files that changed from the base of the PR and between 45648bb and 17f34e6.

📒 Files selected for processing (2)
  • src/agent/service/registration.test.ts
  • src/agent/service/registration.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The heartbeat POST request now sends an explicit empty JSON object. The heartbeat test verifies that the request body is "{}".

Changes

Heartbeat payload

Layer / File(s) Summary
Heartbeat request and validation
src/agent/service/registration.ts, src/agent/service/registration.test.ts
The heartbeat request sends JSON.stringify({}). The test asserts that the request body is "{}".

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 17f34

The heartbeat now sends the required JSON body while preserving the existing endpoint, authentication, and retry behavior. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: sending a JSON body in the agent service heartbeat request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-service-heartbeat-json-body

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 17f34e6619

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

@kojiwakayama
kojiwakayama added this pull request to the merge queue Sep 2, 2026
@kwakayama
kwakayama removed this pull request from the merge queue due to a manual request Sep 2, 2026

@kwakayama kwakayama 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.

No actionable findings.

The heartbeat now sends the required JSON object at src/agent/service/registration.ts:449 while preserving its existing POST method, authentication headers, endpoint, and abort behavior (src/agent/service/registration.ts:446-451). The regression test pins the exact wire body to "{}" at src/agent/service/registration.test.ts:291-295.

Rubric: correctness 40/40, tests 20/20, reliability/security 15/15, maintainability 15/15, scope/docs 10/10.

Review-Gate:
Reviewer: Codex
Reviewed-SHA: 17f34e6
Score: 100/100
Actionable-Findings: 0
Verdict: APPROVE

@kojiwakayama
kojiwakayama added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit 78ec40a Sep 2, 2026
66 checks passed
@kojiwakayama
kojiwakayama deleted the fix/agent-service-heartbeat-json-body branch September 2, 2026 16:29
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.

2 participants