fix(observe): allow sdk-ts entrypoint in observation hook#614
fix(observe): allow sdk-ts entrypoint in observation hook#614chris-yyau wants to merge 1 commit intoaffaan-m:mainfrom
Conversation
When running Claude Code via the Agent SDK (e.g. Happy), the CLAUDE_CODE_ENTRYPOINT is set to "sdk-ts" instead of "cli". The Layer 1 entrypoint guard in observe.sh only allowed "cli", causing all observations to be silently dropped for SDK users. This adds "sdk-ts" to the allowlist since Agent SDK sessions can be human-interactive. Non-interactive SDK automation is still filtered by the remaining 4 safety layers (ECC_HOOK_PROFILE, ECC_SKIP_OBSERVE, agent_id check, and path exclusions). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughModified entrypoint handling in observe.sh to allow sdk-ts to pass through Layer 1 gating alongside cli, changing the case pattern from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
There was a problem hiding this comment.
Pull request overview
This PR prevents continuous-learning observations from being dropped when Claude Code runs via the Agent SDK by allowing the sdk-ts entrypoint to pass the observation hook’s Layer 1 entrypoint guard.
Changes:
- Allow
CLAUDE_CODE_ENTRYPOINT=sdk-tsto proceed through Layer 1 inobserve.sh. - Add comments clarifying why SDK sessions are allowed and how non-interactive automation is still filtered by Layers 2–5.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Greptile SummaryThis PR fixes a silent observation-drop bug for Claude Code users running via the Agent SDK by adding Key changes:
Notes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["observe.sh triggered (PreToolUse / PostToolUse)"] --> B{"stdin JSON empty?"}
B -- "yes" --> EXIT0["exit 0 (no-op)"]
B -- "no" --> C{"disabled marker\nexists?"}
C -- "yes" --> EXIT0
C -- "no" --> D{"Layer 1:\nCLAUDE_CODE_ENTRYPOINT"}
D -- "cli ✅\nsdk-ts ✅ (NEW)" --> E{"Layer 2:\nECC_HOOK_PROFILE=minimal?"}
D -- "anything else" --> EXIT0
E -- "yes" --> EXIT0
E -- "no" --> F{"Layer 3:\nECC_SKIP_OBSERVE=1?"}
F -- "yes" --> EXIT0
F -- "no" --> G{"Layer 4:\nagent_id present?"}
G -- "yes" --> EXIT0
G -- "no" --> H{"Layer 5:\ncwd matches\nskip paths?"}
H -- "yes" --> EXIT0
H -- "no" --> I["Detect project context\n(detect-project.sh)"]
I --> J["Parse & scrub tool I/O\n(Python)"]
J --> K["Append to\nobservations.jsonl"]
K --> L["Lazy-start observer\nif enabled"]
L --> M["Throttled SIGUSR1\nto observer process"]
Last reviewed commit: "fix(observe): allow ..." |
There was a problem hiding this comment.
No issues found across 1 file
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
leegonzales
left a comment
There was a problem hiding this comment.
Hit it.
Clean single-line fix with good documentation. The sdk-ts entrypoint should absolutely be allowed through Layer 1 — Agent SDK sessions via Happy and similar tools are human-interactive and deserve observation. The remaining safety layers (2-5) properly filter automation.
One note: this doesn't address the existing observe.sh falls back to legacy output fields when tool_response is null test failure on main — that's an unrelated ENOENT issue in the test harness, not in the entrypoint logic.
Reviewed by Servitor (heartbeat 7).
Summary
CLAUDE_CODE_ENTRYPOINTis set tosdk-tsinstead ofcliobserve.shonly allowedcli, causing all observations to be silently dropped for SDK users — the continuous learning system was completely non-functionalsdk-tsto the allowlist since Agent SDK sessions can be human-interactiveChanges
skills/continuous-learning-v2/hooks/observe.sh: Addsdk-tsto the Layer 1caseentrypoint allowlist (1 line changed)Test plan
CLAUDE_CODE_ENTRYPOINT=sdk-tsno longer causesobserve.shto exit early~/.claude/homunculus/projects/<hash>/observations.jsonl🤖 Generated with Claude Code
via Happy
Summary by cubic
Fixes dropped observations for Agent SDK sessions by allowing the
sdk-tsentrypoint in the observation hook. Restores continuous learning for interactive SDK runs while non-interactive automation stays blocked by later layers.cli|sdk-tsin Layer 1 entrypoint check inskills/continuous-learning-v2/hooks/observe.sh.ECC_HOOK_PROFILE,ECC_SKIP_OBSERVE,agent_id, path exclusions) still filter automation.Written for commit 2fb047d. Summary will update on new commits.
Summary by CodeRabbit