Skip to main content

Keep large tool results out of the prompt

Large tool results can dominate later model prompts if every result is copied into the conversation on every turn. ISH can hide sensitive values, store large results outside the conversation, and keep only a short reference in history. The next tool can still receive the full stored result when it needs it.

In this page, “shorten” means replacing older tool output in the conversation with a short note. The original result remains available to tools that need it.

from ish import Agent, ContextOffloadInterceptor

agent = Agent(
name="log_reader",
model="gpt-4o-mini",
instructions="Inspect logs and report the relevant findings.",
context_offload=ContextOffloadInterceptor(
max_bytes=32_000,
offload_dir=".offload",
preview_chars=800,
),
auto_virtualize=True,
virtualize_threshold=600,
tombstone_observations=True,
tombstone_threshold=150,
)

How large tool results are handled​

A tool can return far more text than the model needs to continue. Configure one or more of these stages to keep prompts focused while preserving access to the full result.

Save a result as a file​

Enable context_offload when you want the full text on disk and a short preview in the conversation. Keep the offload directory available to any process that needs to read those files later.

Store a result behind a reference​

Enable auto_virtualize when later tools need the full value but the model does not need to see it all at once. The prompt receives a compact reference; authorized tools can use that reference as an argument.

Shorten older results​

Enable tombstone_observations to replace older, large tool results in the active conversation with a short notice. The original result remains available to tools during the run.

Choosing the right stage​

NeedChoosePrompt impact
Keep full output on diskFile offloadShows a short preview and file location
Let later tools use the full valueVirtualizationShows a compact reference
Reduce older conversation contentShorten old resultsReplaces older results with a short note

Keep the configured offload directory available to downstream tools and resumed runs. For archiving older conversation turns across long multi-turn runs, see conversation compaction; for shared mutable task state, see Blackboard.