Skip to content

fix(observe): allow sdk-ts entrypoint in observation hook#614

Open
chris-yyau wants to merge 1 commit intoaffaan-m:mainfrom
chris-yyau:fix/sdk-ts-entrypoint-allowlist
Open

fix(observe): allow sdk-ts entrypoint in observation hook#614
chris-yyau wants to merge 1 commit intoaffaan-m:mainfrom
chris-yyau:fix/sdk-ts-entrypoint-allowlist

Conversation

@chris-yyau
Copy link

@chris-yyau chris-yyau commented Mar 18, 2026

Summary

  • When running Claude Code via the Agent SDK (e.g. Happy), 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 — the continuous learning system was completely non-functional
  • This adds sdk-ts to the allowlist since Agent SDK sessions can be human-interactive

Changes

  • skills/continuous-learning-v2/hooks/observe.sh: Add sdk-ts to the Layer 1 case entrypoint allowlist (1 line changed)
  • Added comment documenting that non-interactive SDK automation is still filtered by the remaining 4 safety layers (ECC_HOOK_PROFILE, ECC_SKIP_OBSERVE, agent_id, path exclusions)

Test plan

  • Verified CLAUDE_CODE_ENTRYPOINT=sdk-ts no longer causes observe.sh to exit early
  • Verified project-scoped observations are written to ~/.claude/homunculus/projects/<hash>/observations.jsonl
  • Verified non-interactive layers (2-5) still filter automated sessions
  • Codex review PASSED

🤖 Generated with Claude Code
via Happy


Summary by cubic

Fixes dropped observations for Agent SDK sessions by allowing the sdk-ts entrypoint in the observation hook. Restores continuous learning for interactive SDK runs while non-interactive automation stays blocked by later layers.

  • Bug Fixes
    • Allow cli|sdk-ts in Layer 1 entrypoint check in skills/continuous-learning-v2/hooks/observe.sh.
    • Add comment noting layers 2–5 (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

  • Bug Fixes
    • Improved handling of SDK TypeScript sessions to allow them to continue processing instead of being prematurely stopped, enabling better support for non-interactive SDK workflows.

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>
Copilot AI review requested due to automatic review settings March 18, 2026 20:55
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 20bb401d-715c-4924-814c-cc32779f5951

📥 Commits

Reviewing files that changed from the base of the PR and between 4bdbf57 and 2fb047d.

📒 Files selected for processing (1)
  • skills/continuous-learning-v2/hooks/observe.sh

📝 Walkthrough

Walkthrough

Modified entrypoint handling in observe.sh to allow sdk-ts to pass through Layer 1 gating alongside cli, changing the case pattern from "cli) ;;" to "cli|sdk-ts) ;;". Added descriptive comments for sdk-ts handling. This prevents non-human interactive SDK sessions from being filtered out at the initial gating layer.

Changes

Cohort / File(s) Summary
Entrypoint Gating Logic
skills/continuous-learning-v2/hooks/observe.sh
Modified case statement to include sdk-ts alongside cli in Layer 1 entrypoint gating, allowing SDK sessions to proceed past the initial guard. Added contextual comments.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 The gate swings open, sdk-ts walks through,
No longer blocked at Layer One's view,
A rabbit hops past, letting flows renew,
Code gating softens—new paths ring true! ✨

🚥 Pre-merge checks | ✅ 3
✅ 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 and specifically describes the main change: allowing sdk-ts as an entrypoint in the observation hook, which directly matches the changeset's core modification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-ts to proceed through Layer 1 in observe.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-apps
Copy link
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR fixes a silent observation-drop bug for Claude Code users running via the Agent SDK by adding sdk-ts to the Layer 1 entrypoint allowlist in observe.sh. Previously, any session launched with CLAUDE_CODE_ENTRYPOINT=sdk-ts exited at Layer 1 without recording observations, making the continuous-learning system completely non-functional for those users.

Key changes:

  • skills/continuous-learning-v2/hooks/observe.sh: cli|sdk-ts replaces the lone cli in the Layer 1 case pattern (1 line).
  • Three explanatory comments are added documenting the rationale and the fact that Layers 2–5 (ECC_HOOK_PROFILE, ECC_SKIP_OBSERVE, agent_id, and path exclusions) still filter non-interactive SDK automation.

Notes:

  • The fix is minimal, correct, and well-scoped.
  • Layers 2–5 remain unchanged and continue to provide defence-in-depth for automated SDK pipelines.
  • Should additional SDK entrypoint variants emerge (e.g. a future sdk-js or sdk-py), this case list will need a corresponding update — a brief inline comment acknowledging this would help future maintainers, but it is not a blocker.

Confidence Score: 5/5

  • This PR is safe to merge; the change is a single-line addition to a shell case pattern with no risk of regression.
  • The diff is one logical line (adding sdk-ts to an existing allowlist). The remaining safety layers (2–5) are untouched and continue to filter automated SDK sessions. The comments accurately describe the design. No new code paths, no new I/O, no security surface changes relative to what already existed for cli sessions.
  • No files require special attention.

Important Files Changed

Filename Overview
skills/continuous-learning-v2/hooks/observe.sh Adds sdk-ts to the Layer 1 entrypoint allowlist so Agent SDK sessions can pass through to the remaining safety layers (2–5). The one-line logic change is correct and well-commented; no functional regressions introduced.

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"]
Loading

Last reviewed commit: "fix(observe): allow ..."

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Copy link

@leegonzales leegonzales left a comment

Choose a reason for hiding this comment

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

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).

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.

3 participants