@letta-ai/letta-code 0.24.6 → 0.24.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,270 +0,0 @@
1
- ---
2
- name: "modifying-letta-code"
3
- description: "Modify your own Letta Code harness: permission rules, hooks, and agent configuration (model, context window, name, toolset, system prompt). Use when you want to change your own deterministic configuration, not your memory."
4
- ---
5
-
6
- # Modifying Letta Code (Self-Configuration)
7
-
8
- This skill tells you — the agent — how to modify your own **harness**: the deterministic configuration layer around you. Load this skill when you want to change how you run (model, permissions, hooks, toolset, system prompt, name, etc.).
9
-
10
- ## Memory vs Harness
11
-
12
- Before you change anything, know which layer you're in:
13
-
14
- | Layer | What it is | How you change it |
15
- |-------|-----------|-------------------|
16
- | **Memory** | Dynamic state you learn and reorganize (`$MEMORY_DIR`, memfs, conversation history) | Memory tool, file edits in `$MEMORY_DIR`, skill operations |
17
- | **Harness** | Deterministic config (model, permissions, hooks, toolset, system prompt) | This skill — edit `settings.json` or call the Letta API |
18
-
19
- Memory is probabilistic: your notes evolve, your history compacts, your skills get loaded and unloaded. The harness is deterministic: given the same settings, you behave the same way. Don't conflate them — edit memory when you're learning, edit the harness when you're reconfiguring.
20
-
21
- ## Where to make changes
22
-
23
- You have two places to modify harness config:
24
-
25
- ### 1. Settings JSON files (you can edit these directly with Write/Edit)
26
-
27
- | File | Scope | Contents |
28
- |------|-------|----------|
29
- | `~/.letta/settings.json` | User (global) | Permissions, hooks, per-agent settings (`agents[]`), pinning, env vars |
30
- | `./.letta/settings.json` | Project | Permissions, hooks, shared with team via git |
31
- | `./.letta/settings.local.json` | Local | Permissions, hooks, personal overrides (gitignored) |
32
-
33
- Precedence (highest wins): **local > project > user**.
34
-
35
- ### 2. The Letta API (for server-side agent state)
36
-
37
- Your **name**, **description**, **model**, **context window**, and **system prompt** live on the Letta server. To change them, call the Letta API.
38
-
39
- **Base URL:** `https://api.letta.com`
40
- **Docs:** https://docs.letta.com/api-overview/introduction
41
- **Auth:** `Authorization: Bearer $LETTA_API_KEY`
42
-
43
- Your own agent ID is `$LETTA_AGENT_ID` (always available in your environment).
44
-
45
- You can use the Python or TypeScript SDK, or just `curl`:
46
-
47
- ```bash
48
- # Rename yourself
49
- curl -X PATCH "https://api.letta.com/v1/agents/$LETTA_AGENT_ID" \
50
- -H "Authorization: Bearer $LETTA_API_KEY" \
51
- -H "Content-Type: application/json" \
52
- -d '{"name": "new-name"}'
53
- ```
54
-
55
- If you need rich SDK examples, load the `letta-api-client` skill.
56
-
57
- ---
58
-
59
- ## 1. Changing your permissions
60
-
61
- Permissions control which tool calls need user approval. Edit `settings.json` directly, or use the helper script.
62
-
63
- ### Rule syntax
64
-
65
- - **Bash** (prefix match with `:*`): `Bash(npm install:*)`, `Bash(git:*)`, `Bash(curl:*)`
66
- - **Files** (glob): `Read(src/**)`, `Edit(**/*.ts)`, `Write(*.md)`
67
- - **All** (dangerous): `*`, `Bash`, `Read`
68
-
69
- ### Helper: add a rule
70
-
71
- ```bash
72
- python3 <skill-dir>/scripts/add_permission.py \
73
- --rule "Bash(curl:*)" \
74
- --type allow \
75
- --scope user
76
- ```
77
-
78
- ### Direct edit (in `settings.json`)
79
-
80
- ```json
81
- {
82
- "permissions": {
83
- "allow": ["Bash(npm:*)", "Read(src/**)"],
84
- "deny": ["Bash(rm -rf:*)"],
85
- "ask": []
86
- }
87
- }
88
- ```
89
-
90
- After editing, your new rules apply on your next restart. In-session additions via the approval UI go into session-only memory and are cleared on exit.
91
-
92
- ---
93
-
94
- ## 2. Adding hooks
95
-
96
- Hooks let you run a shell command or LLM prompt in response to events. Use them to log activity, enforce policy, auto-format, or gate actions.
97
-
98
- ### Events
99
-
100
- **Tool events** (need a `matcher`):
101
- - `PreToolUse` — before a tool runs (can block)
102
- - `PostToolUse` — after a tool succeeds
103
- - `PostToolUseFailure` — after a tool fails (stderr fed back to you)
104
- - `PermissionRequest` — when a permission dialog shows (can allow/deny)
105
-
106
- **Simple events** (no matcher):
107
- - `UserPromptSubmit` — user sends a prompt (can block)
108
- - `Stop` — you finish responding (can block)
109
- - `SubagentStop` — a subagent finishes
110
- - `PreCompact` — before context compaction
111
- - `SessionStart`, `SessionEnd`, `Notification`
112
-
113
- ### Hook types
114
-
115
- **Command** — runs a shell command:
116
- ```json
117
- {"type": "command", "command": "echo $TOOL_INPUT >> ~/audit.log", "timeout": 60000}
118
- ```
119
-
120
- **Prompt** — sends event JSON to an LLM for evaluation:
121
- ```json
122
- {"type": "prompt", "prompt": "Is this safe? Input: $ARGUMENTS", "model": "gpt-5.2"}
123
- ```
124
- Supported events: `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`, `UserPromptSubmit`, `Stop`, `SubagentStop`.
125
-
126
- ### Helper: add a hook
127
-
128
- ```bash
129
- python3 <skill-dir>/scripts/add_hook.py \
130
- --event PreToolUse \
131
- --matcher Bash \
132
- --type command \
133
- --command 'echo "bash: $TOOL_INPUT" >> ~/.letta/audit.log' \
134
- --scope user
135
- ```
136
-
137
- ### Direct edit (in `settings.json`)
138
-
139
- ```json
140
- {
141
- "hooks": {
142
- "PreToolUse": [
143
- {
144
- "matcher": "Bash",
145
- "hooks": [{"type": "command", "command": "echo $TOOL_INPUT >> audit.log"}]
146
- }
147
- ],
148
- "Stop": [
149
- {"hooks": [{"type": "command", "command": "say done"}]}
150
- ]
151
- }
152
- }
153
- ```
154
-
155
- Matchers: exact (`"Bash"`), multiple (`"Edit|Write"`), all (`"*"`).
156
-
157
- ---
158
-
159
- ## 3. Changing your agent configuration
160
-
161
- Agent config splits between the Letta server and local settings.
162
-
163
- ### Server-side fields (use the Letta API)
164
-
165
- Use `PATCH /v1/agents/{agent_id}` with `$LETTA_AGENT_ID`.
166
-
167
- **Change your model and context window:**
168
- ```bash
169
- curl -X PATCH "https://api.letta.com/v1/agents/$LETTA_AGENT_ID" \
170
- -H "Authorization: Bearer $LETTA_API_KEY" \
171
- -H "Content-Type: application/json" \
172
- -d '{
173
- "llm_config": {
174
- "model": "claude-sonnet-4.5",
175
- "model_endpoint_type": "anthropic",
176
- "context_window": 200000
177
- }
178
- }'
179
- ```
180
-
181
- **Rename yourself:**
182
- ```bash
183
- curl -X PATCH "https://api.letta.com/v1/agents/$LETTA_AGENT_ID" \
184
- -H "Authorization: Bearer $LETTA_API_KEY" \
185
- -H "Content-Type: application/json" \
186
- -d '{"name": "draft-v2"}'
187
- ```
188
-
189
- **Update your description:**
190
- ```bash
191
- curl -X PATCH "https://api.letta.com/v1/agents/$LETTA_AGENT_ID" \
192
- -H "Authorization: Bearer $LETTA_API_KEY" \
193
- -H "Content-Type: application/json" \
194
- -d '{"description": "..."}'
195
- ```
196
-
197
- **Update your system prompt (use with care — system prompt is structural):**
198
- ```bash
199
- curl -X PATCH "https://api.letta.com/v1/agents/$LETTA_AGENT_ID" \
200
- -H "Authorization: Bearer $LETTA_API_KEY" \
201
- -H "Content-Type: application/json" \
202
- -d '{"system": "You are..."}'
203
- ```
204
-
205
- For Python / TypeScript SDK usage, see `docs.letta.com/api-overview/introduction` or load the `letta-api-client` skill.
206
-
207
- ### Local per-agent harness (edit `~/.letta/settings.json`)
208
-
209
- The `agents[]` array stores per-agent harness preferences you can edit directly:
210
-
211
- ```json
212
- {
213
- "agents": [
214
- {
215
- "agentId": "agent-abc123",
216
- "baseUrl": "https://api.letta.com",
217
- "pinned": true,
218
- "memfs": { "enabled": true },
219
- "toolset": "full",
220
- "systemPromptPreset": "letta-code-v2"
221
- }
222
- ]
223
- }
224
- ```
225
-
226
- - **`toolset`** — which tool set to load for this agent
227
- - **`memfs.enabled`** — whether the memory filesystem is active
228
- - **`systemPromptPreset`** — which preset was last applied (informational; the actual system prompt is server-side)
229
- - **`pinned`** — show in the quick-switch list
230
-
231
- Find your own entry by matching `agentId === $LETTA_AGENT_ID`, then edit the fields you need.
232
-
233
- ---
234
-
235
- ## Quick reference: what you want to change
236
-
237
- | Change | What to do |
238
- |--------|-----------|
239
- | Auto-approve `curl` commands | `add_permission.py --rule "Bash(curl:*)" --type allow --scope user` |
240
- | Block all `rm -rf` | Add `"Bash(rm -rf:*)"` to `permissions.deny` in `settings.json` |
241
- | Log every Bash command | `add_hook.py --event PreToolUse --matcher Bash --type command --command '...' --scope user` |
242
- | Auto-format after edits | `add_hook.py --event PostToolUse --matcher "Edit\|Write" --type command --command 'prettier ...' --scope project` |
243
- | Gate edits with an LLM check | `add_hook.py --event PreToolUse --matcher Edit --type prompt --prompt '...' --scope user` |
244
- | Change your model | `PATCH /v1/agents/$LETTA_AGENT_ID` with `llm_config.model` |
245
- | Change your context window | `PATCH /v1/agents/$LETTA_AGENT_ID` with `llm_config.context_window` |
246
- | Rename yourself | `PATCH /v1/agents/$LETTA_AGENT_ID` with `name` |
247
- | Update your description | `PATCH /v1/agents/$LETTA_AGENT_ID` with `description` |
248
- | Modify your system prompt | `PATCH /v1/agents/$LETTA_AGENT_ID` with `system` |
249
- | Pin yourself for quick-switch | Add `agentId` to `pinnedAgents` in `~/.letta/settings.json` |
250
- | Change toolset | Edit `agents[].toolset` in `~/.letta/settings.json` |
251
- | Disable memfs | Edit `agents[].memfs.enabled = false` in `~/.letta/settings.json` (and update system prompt via API if needed) |
252
- | See what's currently set | `python3 <skill-dir>/scripts/show_config.py` |
253
-
254
- ---
255
-
256
- ## After making changes
257
-
258
- - **`settings.json` changes** — take effect on next session restart. Your current session keeps the old values.
259
- - **Letta API changes** — apply immediately at the server level, but the in-memory agent config held by your current session may not reflect them until next restart.
260
- - **System prompt / model changes** — always start a fresh conversation after to get a clean context with the new config.
261
-
262
- ## Helper scripts in this skill
263
-
264
- | Script | Purpose |
265
- |--------|---------|
266
- | `scripts/add_permission.py` | Add an allow/deny/ask rule to any scope |
267
- | `scripts/add_hook.py` | Add a command or prompt hook to any event |
268
- | `scripts/show_config.py` | Show merged permissions, hooks, and per-agent settings across all scopes |
269
-
270
- All three accept `--scope user|project|local`. Run `--help` for full usage.