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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27db56c2-a9e0-4a55-b6d8-e35ced75eb4a

📥 Commits

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

📒 Files selected for processing (21)
  • 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/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/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/data/config-reference.json
  • src/config/sound.rs
  • src/detect/manifest.rs
  • src/detect/manifests/letta.toml
  • src/detect/mod.rs
  • src/integration/mod.rs
  • src/integration/targets.rs
  • src/integration/tests.rs
  • src/main.rs
  • website/agent-detection/letta.toml
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/next/website/src/content/docs/cli-reference.mdx
  • docs/next/website/src/content/docs/agents.mdx
  • docs/next/website/src/content/docs/agent-automation.mdx
  • src/detect/manifest.rs
  • docs/next/website/src/content/docs/ja/agents.mdx
  • docs/next/CHANGELOG.md

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


📝 Walkthrough

Walkthrough

Herdr adds Letta Code detection, session hooks, integration installation, native conversation restore, configuration entries, API and CLI support, localized documentation, and changelog entries.

Changes

Letta Code support

Layer / File(s) Summary
Letta process and screen detection
src/detect/*, website/agent-detection/*
Letta process identification, interactive-command filtering, aliases, screen-manifest registration, terminal-state rules, and tests are added.
Letta session integration lifecycle
src/integration/*
Unix and Windows session hooks report Letta session metadata. Installation and removal update ~/.letta/settings.json and manage files transactionally.
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, docs/next/website/src/data/config-reference.json
Letta becomes an integration target and supported agent kind. Native resume handles conversation IDs and default:<agent-id> references. Sound and CJK IME configuration accept Letta names.
Letta documentation and release metadata
docs/next/website/src/content/docs/*, docs/next/CHANGELOG.md
English, Japanese, and Chinese documentation describe Letta installation, detection, session reporting, restoration, and CLI support. The changelog records Letta support and other fixes.

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

Merge Risk: 🔵 Low · up to daf9d

The PR adds Letta session detection, conversation restore, and a user-level SessionStart hook. It is mergeable with explicit owner awareness because status may remain stale after approval, session identity reporting may fail if hook settings are rejected, and interrupted or concurrent setup changes could leave configuration inconsistent.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.07% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 61 functions across 17 files. (14 skipped… 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 and concisely summarizes the main changes: Letta Code detection and conversation restoration.
Description check ✅ Passed The description directly covers the Letta Code detection, state tracking, session hooks, conversation restoration, exposed interfaces, validation, and referenced issue.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 36.07% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 61 functions across 17 files. (14 skipped: 14 unsupported.)

  • 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 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

This PR adds Letta Code detection, managed startup, session reporting and native conversation restoration, plus installation, configuration, API, and documentation support.

  • Recognizes interactive Letta processes and maps OSC and screen evidence to shared agent states.
  • Installs an optional session-only hook that reports ordinary and default conversations.
  • Restores reported conversations through Letta-specific command-line arguments.
  • Exposes Letta through integration commands, schemas, configuration, and release documentation.

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 the Letta agent identity, aliases, managed executable mapping, and interactive-process filtering.
src/detect/manifests/letta.toml Defines prioritized OSC and screen rules for Letta idle, working, blocked, and unknown states.
src/agent_resume.rs Converts ordinary and default Letta session references into native conversation restore commands.
src/integration/targets.rs Adds Letta hook installation, settings registration, staged publication, rollback, and uninstallation.
src/integration/assets/letta/herdr-agent-session.sh Reports Unix Letta SessionStart conversation identity to the owning Herdr pane.
src/integration/assets/letta/herdr-agent-session.ps1 Implements equivalent session reporting for Windows.
src/integration/registry.rs Registers Letta command availability, platform support, installed asset path, and integration version.
src/api/schema/integrations.rs Adds Letta to the typed integration target API contract.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  P[Letta foreground process] --> D[Process detection]
  D --> M[OSC and screen manifest]
  M --> S[Agent lifecycle state]
  H[Optional SessionStart hook] --> R[Native session reference]
  R --> X[Saved session snapshot]
  X --> C[Letta resume command]
Loading

Reviews (6): 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
@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?

@just-cameron

Copy link
Copy Markdown

Yeah, taking a look now. Thanks!

@just-cameron

Copy link
Copy Markdown

Okay -- battletested and found one blocking bug. You can see my agent's fix in this commit.

I have included my agent's report for your perusal.

As a side note, one of our users added a lot of bells and whistles to improve the herdr/letta experience, but I think it is out of scope for this PR. Would you like me to open issues for some of the features I liked in his work? https://github.com/klittle32/letta-herdr-mod

Agent report

Tested this thoroughly against exact PR head f96c29477ec8c842a122eb04548bb3f83590de04 using Letta Code 0.30.30 on macOS.

What worked:

  • Letta process detection
  • Default conversation restore
  • Named conversation restore (local-conv-24)
  • Live idle → working → idle transitions during a real model turn
  • Live blocked → idle transitions using an AskUserQuestion interaction
  • SessionStart identity reporting through herdr:letta
  • Clean return to the shell after Letta exits

The 11 Letta-focused tests pass, as do strict Clippy, manifest validation, and the documentation builds.

I found one startup edge case:

  1. Start Letta with an invalid --agent value.
  2. Letta opens its profile selector instead of a conversation.
  3. Herdr can report the agent as idle and interactive_ready: true, causing agent start to succeed even though Letta is still waiting for profile selection.

agent explain showed this came from default_known_agent_idle_fallback; there was no explicit live-idle match. The settled profile-selector screen can be recognized, but there is also an initial rendering race where the generic fallback can mark startup ready before that selector is visible. I think startup should remain pending or unknown until Letta exposes explicit idle composer evidence.

The PR currently conflicts with master. I rebased it locally onto 7d56b4c5; only the changelog required manual conflict resolution.

One note on validation: the full just check run still hits live_handoff_keeps_unmanaged_agent_name_bound_to_saved_session, but I reproduced that same failure on exact origin/master, so it does not appear related to this PR.

Overall, the integration works well in real use. The false-ready profile-selector case is the only Letta-specific issue I found.

refs #3106

Co-authored-by: Cameron <cameron@pfiffer.org>
@ogulcancelik
ogulcancelik force-pushed the issue/3106-letta-code branch from f96c294 to daf9d95 Compare August 27, 2026 13:29
@ogulcancelik

Copy link
Copy Markdown
Collaborator Author

Agreed—the known-agent idle fallback could make startup succeed before Letta showed live composer evidence. I applied your manifest fix and regression coverage, then rebased the PR onto current master. just check passes. Thanks for the thorough real-world validation.

@ogulcancelik

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ogulcancelik

Copy link
Copy Markdown
Collaborator Author

@just-cameron could you re-review please and verify if it works with letta?

@langri-sha

Copy link
Copy Markdown

FWIW, tested dev with latest v0.31.5 for simple case that Letta now appears in the agent list and the indicators, agent restoration work alright.

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.

4 participants