Skip to content

Commit a5a6b21

Browse files
Merge pull request #484 from anthropics/isabella/unwrap-blockquote-callouts
fix(tool_use): unwrap blockquote callouts in context engineering notebook
2 parents 50871d8 + 2fcb7b4 commit a5a6b21

1 file changed

Lines changed: 5 additions & 30 deletions

File tree

tool_use/context_engineering/context_engineering_tools.ipynb

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,14 +1482,7 @@
14821482
"\n",
14831483
"The `instructions` parameter lets you replace the default summarization prompt entirely. The [compaction docs](https://platform.claude.com/docs/en/build-with-claude/compaction#custom-summarization-instructions) give the default prompt verbatim:\n",
14841484
"\n",
1485-
"> You have written a partial transcript for the initial task above.\n",
1486-
"> Please write a summary of the transcript. The purpose of this summary\n",
1487-
"> is to provide continuity so you can continue to make progress towards\n",
1488-
"> solving the task in a future context, where the raw history above may\n",
1489-
"> not be accessible and will be replaced with this summary. Write down\n",
1490-
"> anything that would be helpful, including the state, next steps,\n",
1491-
"> learnings etc. You must wrap your summary in a `<summary></summary>`\n",
1492-
"> block.\n",
1485+
"> You have written a partial transcript for the initial task above. Please write a summary of the transcript. The purpose of this summary is to provide continuity so you can continue to make progress towards solving the task in a future context, where the raw history above may not be accessible and will be replaced with this summary. Write down anything that would be helpful, including the state, next steps, learnings etc. You must wrap your summary in a `<summary></summary>` block.\n",
14931486
"\n",
14941487
"This helps give you a place to start. However, custom `instructions` don't supplement this prompt — they completely replace it. So if you provide your own, you're responsible for the full framing. The docs' example for a coding context is `\"Focus on preserving code snippets, variable names, and technical decisions.\"`\n",
14951488
"\n",
@@ -1639,9 +1632,7 @@
16391632
"\n",
16401633
"Our API provides this natively as the `clear_tool_uses_20250919` context edit. It handles token counting and triggering server-side, preserves block pairing, and lets you exempt specific tools from clearing (useful when the memory tool is also active, as we'll see later). When clearing fires, the response includes `context_management.applied_edits` with details on how many tool uses were cleared and how many tokens were freed.\n",
16411634
"\n",
1642-
"> There's also `clear_thinking_20251015` for extended-thinking blocks.\n",
1643-
"> Same config shape, different `type`. It must be the first entry in the\n",
1644-
"> `edits` array if you're using both.\n",
1635+
"> There's also `clear_thinking_20251015` for extended-thinking blocks. Same config shape, different `type`. It must be the first entry in the `edits` array if you're using both.\n",
16451636
"\n",
16461637
"**API Documentation:** [Context editing — platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/context-editing)\n",
16471638
"\n",
@@ -2030,11 +2021,7 @@
20302021
"id": "a39b0683",
20312022
"metadata": {},
20322023
"source": [
2033-
"> Security note: the `_resolve` method guards against path traversal\n",
2034-
"> (`../../etc/passwd`). In production you'd also want to cap file sizes and\n",
2035-
"> total directory size. See the\n",
2036-
"> [Memory Cookbook](https://platform.claude.com/cookbook/tool-use-memory-cookbook)\n",
2037-
"> for deeper memory patterns.\n",
2024+
"> Security note: the `_resolve` method guards against path traversal (`../../etc/passwd`). In production you'd also want to cap file sizes and total directory size. See the [Memory Cookbook](https://platform.claude.com/cookbook/tool-use-memory-cookbook) for deeper memory patterns.\n",
20382025
"\n",
20392026
"### Demonstrating the benefit\n",
20402027
"\n",
@@ -2511,23 +2498,11 @@
25112498
"\n",
25122499
"The Claude Code design shows that memory can take different shapes for the same agent; one form written by the user, another written by the model. The same applies to compaction and clearing: each has configuration knobs (trigger thresholds, custom instructions, which tools to exclude) that let you tune behavior to your use case. This is why the prompting and configuration guidance in the \"Implementing effectively\" sections above matters: the default behavior is a starting point, but the right settings depend on what your agent actually does.\n",
25132500
"\n",
2514-
"> **Note on `exclude_tools`**: when combining clearing with the memory tool,\n",
2515-
"> the `exclude_tools: [\"memory\"]` setting (shown in the config below)\n",
2516-
"> prevents the agent's memory reads and writes from being cleared. Without\n",
2517-
"> it, the agent could lose track of what it just saved. The\n",
2518-
"> [memory tool docs](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool#using-with-context-editing)\n",
2519-
"> recommend this explicitly when layering the two.\n",
2501+
"> **Note on `exclude_tools`**: when combining clearing with the memory tool, the `exclude_tools: [\"memory\"]` setting (shown in the config below) prevents the agent's memory reads and writes from being cleared. Without it, the agent could lose track of what it just saved. The [memory tool docs](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool#using-with-context-editing) recommend this explicitly when layering the two.\n",
25202502
"\n",
25212503
"Below we run the research agent with all three primitives active at once and trace what each one does over the course of the session.\n",
25222504
"\n",
2523-
"> **Note on the config**: both triggers are set above the first\n",
2524-
"> batch's size (~167K) so the trajectory tracks the baseline through\n",
2525-
"> batch 1. When batch 2 pushes context to ~330K, clearing fires first\n",
2526-
"> (keep=6 drops the earliest reads, leaving ~210K) and compaction\n",
2527-
"> fires on what clearing left. Memory is active throughout. This\n",
2528-
"> tuning is for demonstration, so that all three primitives activate\n",
2529-
"> in one run. A production config depends on your agent's specific\n",
2530-
"> context-growth pattern."
2505+
"> **Note on the config**: both triggers are set above the first batch's size (~167K) so the trajectory tracks the baseline through batch 1. When batch 2 pushes context to ~330K, clearing fires first (keep=6 drops the earliest reads, leaving ~210K) and compaction fires on what clearing left. Memory is active throughout. This tuning is for demonstration, so that all three primitives activate in one run. A production config depends on your agent's specific context-growth pattern."
25312506
]
25322507
},
25332508
{

0 commit comments

Comments
 (0)