Skip to content

Commit 7962263

Browse files
committed
docs: update editing
1 parent 6467acc commit 7962263

File tree

2 files changed

+163
-7
lines changed

2 files changed

+163
-7
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
> Related to Issue ()
21

3-
# Tasks
4-
Please ensure your pull request meets the following requirements:
5-
- [ ] PR Task 1
6-
- [ ] PR Task 2
7-
- [ ] ...
2+
3+
# Why we need this PR?
4+
> This should close Issue ()
5+
...
86

97
# Impact Areas
108
Which part of Acontext would this feature affect?
@@ -15,7 +13,15 @@ Which part of Acontext would this feature affect?
1513
- [ ] Dashboard
1614
- [ ] CLI Tool
1715
- [ ] Documentation
18-
- [ ] Other: please_specify_here
16+
- [ ] Other: ...
17+
18+
19+
# Implementation Tasks
20+
Please ensure your pull request meets the following requirements:
21+
- [ ] PR Task 1
22+
- [ ] PR Task 2
23+
- [ ] ...
24+
1925

2026
# Checklist
2127
- [ ] Open your pull request against the `dev` branch.

docs/store/editing.mdx

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,28 @@ It will:
108108
- Removes messages from oldest to newest
109109
- Maintains tool-call/tool-result pairing (when removing a tool-call, its corresponding tool-result is also removed)
110110

111+
**Example Output:**
112+
113+
<CodeGroup>
114+
```json Before (5 messages, ~25,000 tokens)
115+
[
116+
{"role": "user", "content": "What's the weather in NYC?"},
117+
{"role": "assistant", "content": "...", "tool_calls": [...]},
118+
{"role": "tool", "content": "Temperature: 72°F"},
119+
{"role": "assistant", "content": "The weather in NYC is 72°F and sunny."},
120+
{"role": "user", "content": "What about Boston?"}
121+
]
122+
```
123+
124+
```json After (limit_tokens: 20000)
125+
[
126+
{"role": "assistant", "content": "The weather in NYC is 72°F and sunny."},
127+
{"role": "user", "content": "What about Boston?"}
128+
]
129+
```
130+
</CodeGroup>
131+
132+
**Usage:**
111133
<CodeGroup>
112134
```python Python
113135
# Limit session to 20,000 tokens
@@ -146,6 +168,35 @@ This strategy will replace the oldest tool results' content with a placeholder t
146168
- `keep_recent_n_tool_results` (optional, default: 3): Number of most recent tool results to keep with original content
147169
- `tool_result_placeholder` (optional, default: "Done"): Custom text to replace old tool results with
148170

171+
**Example Output:**
172+
173+
<CodeGroup>
174+
```json Before (3 tool results with full content)
175+
[
176+
{"role": "user", "content": "Check weather in 5 cities"},
177+
{"role": "assistant", "tool_calls": [{"id": "1", "name": "get_weather", "arguments": "{\"city\":\"NYC\"}"}]},
178+
{"role": "tool", "tool_call_id": "1", "content": "Temperature: 72°F, Humidity: 65%, Wind: 10mph..."},
179+
{"role": "assistant", "tool_calls": [{"id": "2", "name": "get_weather", "arguments": "{\"city\":\"LA\"}"}]},
180+
{"role": "tool", "tool_call_id": "2", "content": "Temperature: 85°F, Humidity: 45%, Wind: 5mph..."},
181+
{"role": "assistant", "tool_calls": [{"id": "3", "name": "get_weather", "arguments": "{\"city\":\"Chicago\"}"}]},
182+
{"role": "tool", "tool_call_id": "3", "content": "Temperature: 68°F, Humidity: 70%, Wind: 15mph..."}
183+
]
184+
```
185+
186+
```json After (keep_recent_n_tool_results: 1)
187+
[
188+
{"role": "user", "content": "Check weather in 5 cities"},
189+
{"role": "assistant", "tool_calls": [{"id": "1", "name": "get_weather", "arguments": "{\"city\":\"NYC\"}"}]},
190+
{"role": "tool", "tool_call_id": "1", "content": "Done"},
191+
{"role": "assistant", "tool_calls": [{"id": "2", "name": "get_weather", "arguments": "{\"city\":\"LA\"}"}]},
192+
{"role": "tool", "tool_call_id": "2", "content": "Done"},
193+
{"role": "assistant", "tool_calls": [{"id": "3", "name": "get_weather", "arguments": "{\"city\":\"Chicago\"}"}]},
194+
{"role": "tool", "tool_call_id": "3", "content": "Temperature: 68°F, Humidity: 70%, Wind: 15mph..."}
195+
]
196+
```
197+
</CodeGroup>
198+
199+
**Usage:**
149200
<CodeGroup>
150201
```python Python
151202
# With explicit parameters
@@ -193,6 +244,105 @@ const editedSession = await client.sessions.getMessages('session-uuid', {
193244
```
194245
</CodeGroup>
195246

247+
### Remove Tool Call Params
248+
This strategy removes parameters from old tool-call parts to reduce the session context, while keeping the most recent N tool calls with their full parameters intact.
249+
250+
This is particularly useful when you have many tool calls in your session history and want to reduce token usage by removing the detailed arguments from older tool calls, while still maintaining the tool call structure (ID and name) so that tool-results can still reference them.
251+
252+
**Parameters:**
253+
- `keep_recent_n_tool_calls` (optional, default: 3): Number of most recent tool calls to keep with full parameters
254+
255+
**How it works:**
256+
- Keeps the most recent N tool calls with their original parameters
257+
- Replaces older tool call arguments with empty JSON `{}`
258+
- Tool call ID and name remain intact so tool-results can still reference them
259+
260+
**Example Output:**
261+
262+
<CodeGroup>
263+
```json Before (3 tool calls with full arguments)
264+
[
265+
{"role": "user", "content": "Analyze sales data for all regions"},
266+
{"role": "assistant", "tool_calls": [
267+
{"id": "call_1", "name": "query_database", "arguments": "{\"query\":\"SELECT * FROM sales WHERE region='North' AND date > '2024-01-01'\",\"limit\":1000}"}
268+
]},
269+
{"role": "tool", "tool_call_id": "call_1", "content": "Results: 1500 rows..."},
270+
{"role": "assistant", "tool_calls": [
271+
{"id": "call_2", "name": "query_database", "arguments": "{\"query\":\"SELECT * FROM sales WHERE region='South' AND date > '2024-01-01'\",\"limit\":1000}"}
272+
]},
273+
{"role": "tool", "tool_call_id": "call_2", "content": "Results: 1200 rows..."},
274+
{"role": "assistant", "tool_calls": [
275+
{"id": "call_3", "name": "calculate_metrics", "arguments": "{\"data\":[...],\"metrics\":[\"average\",\"total\",\"growth\"]}"}
276+
]},
277+
{"role": "tool", "tool_call_id": "call_3", "content": "Average: $5000, Total: $2.5M..."}
278+
]
279+
```
280+
281+
```json After (keep_recent_n_tool_calls: 1)
282+
[
283+
{"role": "user", "content": "Analyze sales data for all regions"},
284+
{"role": "assistant", "tool_calls": [
285+
{"id": "call_1", "name": "query_database", "arguments": "{}"}
286+
]},
287+
{"role": "tool", "tool_call_id": "call_1", "content": "Results: 1500 rows..."},
288+
{"role": "assistant", "tool_calls": [
289+
{"id": "call_2", "name": "query_database", "arguments": "{}"}
290+
]},
291+
{"role": "tool", "tool_call_id": "call_2", "content": "Results: 1200 rows..."},
292+
{"role": "assistant", "tool_calls": [
293+
{"id": "call_3", "name": "calculate_metrics", "arguments": "{\"data\":[...],\"metrics\":[\"average\",\"total\",\"growth\"]}"}
294+
]},
295+
{"role": "tool", "tool_call_id": "call_3", "content": "Average: $5000, Total: $2.5M..."}
296+
]
297+
```
298+
</CodeGroup>
299+
300+
**Usage:**
301+
<CodeGroup>
302+
```python Python
303+
# With explicit parameters
304+
edited_session = client.sessions.get_messages(
305+
session_id="session-uuid",
306+
edit_strategies=[
307+
{
308+
"type": "remove_tool_call_params",
309+
"params": {
310+
"keep_recent_n_tool_calls": 5
311+
}
312+
}
313+
],
314+
)
315+
316+
# Using defaults (keeps 3 most recent tool calls)
317+
edited_session = client.sessions.get_messages(
318+
session_id="session-uuid",
319+
edit_strategies=[
320+
{"type": "remove_tool_call_params"}
321+
],
322+
)
323+
```
324+
```typescript TypeScript
325+
// With explicit parameters
326+
const editedSession = await client.sessions.getMessages('session-uuid', {
327+
editStrategies: [
328+
{
329+
type: 'remove_tool_call_params' as const,
330+
params: {
331+
keep_recent_n_tool_calls: 5
332+
}
333+
}
334+
],
335+
});
336+
337+
// Using defaults (keeps 3 most recent tool calls)
338+
const editedSession = await client.sessions.getMessages('session-uuid', {
339+
editStrategies: [
340+
{ type: 'remove_tool_call_params' as const }
341+
],
342+
});
343+
```
344+
</CodeGroup>
345+
196346

197347

198348
## Context Engineering and Editing

0 commit comments

Comments
 (0)