Skip to content

feat: add Letta Code detection and restore - #3107

Open
ogulcancelik wants to merge 1 commit into
masterfrom
issue/3106-letta-code
Open

feat: add Letta Code detection and restore#3107
ogulcancelik wants to merge 1 commit into
masterfrom
issue/3106-letta-code

Conversation

@ogulcancelik

Copy link
Copy Markdown
Collaborator

Summary

  • detect interactive Letta Code processes and track idle, working, and blocked states from OSC signals with screen fallbacks
  • add an optional session-only hook and native conversation restore, including default conversations
  • expose Letta through agent start, integration commands, API schema, config, and release docs

Builds on the initial integration work from @just-cameron in https://github.com/just-cameron/herdr/tree/letta-code-integration.

Validation

  • just check
  • live Letta Code v0.30.28 process, idle detection, hook installation, and default-conversation session reporting

Refs #3106

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Herdr adds Letta Code support across agent detection, session integration, native conversation restoration, CLI targets, configuration, tests, API schemas, and localized documentation.

Changes

Letta Code support

Layer / File(s) Summary
Letta process and screen detection
src/detect/..., website/agent-detection/...
Adds Letta aliases, executable parsing, interactive-process filtering, screen-manifest registration, terminal-state rules, and detection tests.
Letta session integration lifecycle
src/integration/...
Adds Unix and PowerShell session hooks, installation and uninstall flows, ~/.letta path handling, registry entries, CLI dispatch, and integration tests.
Letta targets and native resume
src/api/schema/integrations.rs, src/cli/integration.rs, src/agent_resume.rs, src/config/..., src/main.rs, docs/next/api/herdr-api.schema.json
Adds the Letta integration target, CLI support, native resume argument mapping, sound overrides, configuration names, and API enum values.
Letta documentation and release metadata
docs/next/CHANGELOG.md, docs/next/website/src/content/docs/...
Documents Letta detection, installation, session identity, native resume commands, supported agent kinds, and localized integration details.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: 🟡 Moderate · up to e03e0

The PR adds Letta session integration, but setup can persist a hook reference before the hook is ready, causing later sessions to invoke a broken hook; stale blocked-state detection and hook-setting compatibility concerns also remain. These bounded integration risks should be fixed or explicitly accepted before merging.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant HerdrCLI
  participant LettaSettings
  participant LettaHook
  participant HerdrPane
  User->>HerdrCLI: integration install letta
  HerdrCLI->>LettaSettings: write SessionStart hook
  HerdrCLI->>LettaHook: install managed script
  LettaHook->>HerdrPane: report agent session metadata
  User->>HerdrCLI: resume Letta conversation
  HerdrCLI->>LettaHook: plan letta --conversation arguments
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 54 functions across 17 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: Letta Code detection and native conversation restoration.
Description check ✅ Passed The description directly explains Letta Code detection, session hooks, conversation restore, exposed interfaces, and validation.
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.
✨ 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 issue/3106-letta-code

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.

@kangal-bot kangal-bot added the ai-review Trigger automated AI reviews for pull requests admitted by the PR gate label Aug 22, 2026

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
src/config/sound.rs (1)

47-47: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add an explicit regression assertion for omitted letta.

#[serde(default)] already preserves AgentSoundOverrides::default(). Add an assertion that an absent letta field produces AgentSoundSetting::Default.

src/detect/mod.rs (1)

629-640: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

The bare letta-code/letta path match is broad.

The windows(2) check matches any path that contains a letta-code directory followed by a letta component, outside node_modules. A local checkout path such as /home/user/src/letta-code/letta/build.js would be classified as Letta. The scoped windows(4) match above already covers the published package layout. The is_interactive_letta_process gate limits the damage, so this is a small risk only.

Consider anchoring the fallback to a node_modules or .bin context, or to a trailing component.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aa59483c-24ca-4cc4-8592-87c045048df4

📥 Commits

Reviewing files that changed from the base of the PR and between 1c76079 and 04c821e.

📒 Files selected for processing (39)
  • docs/next/CHANGELOG.md
  • docs/next/api/herdr-api.schema.json
  • docs/next/website/src/content/docs/agent-automation.mdx
  • docs/next/website/src/content/docs/agents.mdx
  • docs/next/website/src/content/docs/cli-reference.mdx
  • docs/next/website/src/content/docs/integrations.mdx
  • docs/next/website/src/content/docs/ja/agent-automation.mdx
  • docs/next/website/src/content/docs/ja/agents.mdx
  • docs/next/website/src/content/docs/ja/cli-reference.mdx
  • docs/next/website/src/content/docs/ja/integrations.mdx
  • docs/next/website/src/content/docs/ja/session-state.mdx
  • docs/next/website/src/content/docs/session-state.mdx
  • docs/next/website/src/content/docs/zh-cn/agent-automation.mdx
  • docs/next/website/src/content/docs/zh-cn/agents.mdx
  • docs/next/website/src/content/docs/zh-cn/cli-reference.mdx
  • docs/next/website/src/content/docs/zh-cn/integrations.mdx
  • docs/next/website/src/content/docs/zh-cn/session-state.mdx
  • docs/next/website/src/data/config-reference.json
  • src/agent_resume.rs
  • src/api/schema/integrations.rs
  • src/cli/integration.rs
  • src/config/model.rs
  • src/config/sidebar.rs
  • src/config/sound.rs
  • src/detect/manifest.rs
  • src/detect/manifests/letta.toml
  • src/detect/mod.rs
  • src/integration/actions.rs
  • src/integration/assets/letta/herdr-agent-session.ps1
  • src/integration/assets/letta/herdr-agent-session.sh
  • src/integration/env.rs
  • src/integration/mod.rs
  • src/integration/registry.rs
  • src/integration/targets.rs
  • src/integration/tests.rs
  • src/integration/types.rs
  • src/main.rs
  • website/agent-detection/index.toml
  • website/agent-detection/letta.toml

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/detect/manifests/letta.toml
Comment thread src/detect/mod.rs
Comment thread src/integration/assets/letta/herdr-agent-session.ps1
Comment thread src/integration/targets.rs Outdated
Comment thread src/main.rs
@ogulcancelik
ogulcancelik force-pushed the issue/3106-letta-code branch from 04c821e to cfeed00 Compare August 22, 2026 02:17
@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds Letta Code as a supported agent with process and screen-state detection, optional session reporting, and native conversation restoration.

  • Registers Letta across agent startup, configuration, integration CLI/API surfaces, and generated documentation.
  • Installs platform-specific SessionStart hooks while preserving screen detection as the lifecycle authority.
  • Restores named conversations and agent-scoped default conversations from persisted session references.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains within the eligible follow-up-review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
src/detect/mod.rs Adds Letta identity aliases, interactive-process filtering, executable selection, and screen-manifest registration.
src/detect/manifests/letta.toml Defines prioritized OSC and screen fallbacks for Letta blocked, working, idle, and uncertain states.
src/integration/targets.rs Adds transactional Letta hook installation and uninstall behavior while preserving unrelated settings and hooks.
src/integration/assets/letta/herdr-agent-session.sh Reports named and agent-scoped default Letta conversations from SessionStart payloads on Unix.
src/integration/assets/letta/herdr-agent-session.ps1 Implements the corresponding silent SessionStart session reporter for Windows.
src/agent_resume.rs Maps persisted Letta conversation references to named or default-conversation restore commands.
src/api/schema/integrations.rs Exposes Letta as an installable integration target through the typed API schema.

Sequence Diagram

sequenceDiagram
    participant User
    participant Herdr
    participant Letta as Letta Code
    participant Hook as SessionStart Hook
    participant Persist as Session Persistence

    User->>Herdr: Start Letta agent
    Herdr->>Letta: letta [arguments]
    Letta-->>Herdr: OSC and screen output
    Herdr->>Herdr: Detect idle, working, or blocked
    Letta->>Hook: SessionStart payload
    Hook->>Herdr: Report conversation reference
    Herdr->>Persist: Save Letta session identity
    Note over Herdr,Persist: After server restoration
    Persist-->>Herdr: Restore session reference
    alt Named conversation
        Herdr->>Letta: "letta --conversation <id>"
    else Default conversation
        Herdr->>Letta: "letta --conversation default --agent <agent-id>"
    end
Loading

Reviews (5): Last reviewed commit: "feat: add Letta Code detection and resto..." | Re-trigger Greptile

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

🧹 Nitpick comments (3)
src/config/sound.rs (1)

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

Cover the Letta-specific lookup with a non-default test.

The current assertion verifies only the default value. It does not verify that a configured value reaches AgentSoundOverrides::for_agent for Agent::Letta. Add letta = "on" to the fixture and assert both the parsed field and the lookup result.

Suggested test extension
 [ui.sound.agents]
 droid = "off"
 claude = "on"
+letta = "on"
 ...
-        assert_eq!(config.ui.sound.agents.letta, AgentSoundSetting::Default);
+        assert_eq!(config.ui.sound.agents.letta, AgentSoundSetting::On);
+        assert_eq!(
+            config
+                .ui
+                .sound
+                .agents
+                .for_agent(Some(crate::detect::Agent::Letta)),
+            AgentSoundSetting::On
+        );
src/detect/mod.rs (1)

692-735: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider normalizing the --flag=value form once.

The list repeats each option twice: once as an exact match and once as a --name= prefix. Splitting the argument at the first = and matching the name once removes the duplication and keeps both forms in sync when the option list changes.

♻️ Possible simplification
-    if cli_args.iter().any(|arg| {
-        matches!(
-            arg.as_str(),
+    if cli_args.iter().any(|arg| {
+        let name = arg.split_once('=').map_or(arg.as_str(), |(name, _)| name);
+        matches!(
+            name,
             "-p" | "--print"

Then drop the starts_with("--…=") chain.

src/integration/targets.rs (1)

1209-1211: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse a single letta_dir() result.

letta_dir() is called twice. Bind it once and derive both paths from it.

♻️ Proposed change
-    let hook_path = letta_dir()?.join("hooks").join(LETTA_HOOK_INSTALL_NAME);
-    let settings_path = letta_dir()?.join("settings.json");
+    let dir = letta_dir()?;
+    let hook_path = dir.join("hooks").join(LETTA_HOOK_INSTALL_NAME);
+    let settings_path = dir.join("settings.json");

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a6b68c80-a89f-46f3-907b-3c80fcdc37c8

📥 Commits

Reviewing files that changed from the base of the PR and between 04c821e and cfeed00.

📒 Files selected for processing (6)
  • docs/next/website/src/data/config-reference.json
  • src/config/sound.rs
  • src/detect/mod.rs
  • src/integration/assets/letta/herdr-agent-session.ps1
  • src/integration/targets.rs
  • src/integration/tests.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@ogulcancelik
ogulcancelik force-pushed the issue/3106-letta-code branch 2 times, most recently from 0e6f70e to 6c0ff7b Compare August 22, 2026 02:25

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

🧹 Nitpick comments (1)
src/integration/targets.rs (1)

1011-1018: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Use a named millisecond timeout constant for the Letta hook. Letta Code v0.30.28 supports both timeout in milliseconds and quiet as a boolean. Replace the unexplained 10_000 literal with LETTA_HOOK_TIMEOUT_MS.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a396887-ed40-43ca-91ce-80b4fa6492ca

📥 Commits

Reviewing files that changed from the base of the PR and between 0e6f70e and 6c0ff7b.

📒 Files selected for processing (3)
  • src/config/sound.rs
  • src/detect/mod.rs
  • src/integration/targets.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@ogulcancelik
ogulcancelik force-pushed the issue/3106-letta-code branch from 6c0ff7b to e03e033 Compare August 22, 2026 12:34

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 25b3509d-f279-4a69-94a2-22d181088986

📥 Commits

Reviewing files that changed from the base of the PR and between 6c0ff7b and e03e033.

📒 Files selected for processing (3)
  • src/integration/mod.rs
  • src/integration/targets.rs
  • src/integration/tests.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/integration/targets.rs Outdated
refs #3106

Co-authored-by: Cameron <cameron@pfiffer.org>
@ogulcancelik
ogulcancelik force-pushed the issue/3106-letta-code branch from e03e033 to f96c294 Compare August 22, 2026 12:47
@ogulcancelik

Copy link
Copy Markdown
Collaborator Author

hey @just-cameron could you verify if this branch works great with letta?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Trigger automated AI reviews for pull requests admitted by the PR gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants