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.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
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,
)
import { Agent } from "ish-harness";
const agent = new Agent({
model: { provider: "openai_chat", name: "gpt-4o-mini" },
instructions: "Inspect logs and report the relevant findings.",
context_offload: {
max_bytes: 32_000,
offload_dir: ".offload",
preview_chars: 800,
},
auto_virtualize: true,
virtualize_threshold: 600,
tombstone_observations: true,
tombstone_threshold: 150,
});
use std::sync::Arc;
use ish_harness::{runner::ContextOffloadConfig, Agent, BlobTable, OpenAIModel, RunnerConfig};
let config = RunnerConfig {
context_offload: Some(ContextOffloadConfig {
max_bytes: 32_000,
offload_dir: ".offload".to_string(),
preview_chars: 800,
}),
blob_table: Some(BlobTable::new(None::<&str>)),
auto_virtualize: true,
virtualize_threshold: 600,
tombstone_observations: true,
tombstone_threshold: 150,
..RunnerConfig::default()
};
let agent = Agent::builder(Arc::new(model))
.instructions("Inspect logs and report the relevant findings.")
.config(config)
.build()?;
result, err := client.Run(ctx, ish.AgentRunRequest{
Model: &ish.AgentModel{Provider: "openai_chat", Name: "gpt-4o-mini"},
SystemPrompt: ish.StringPtr("Inspect logs and report the relevant findings."),
UserPrompt: ish.StringPtr("Review the latest logs."),
ContextOffload: ish.ContextOffloadOptions{
MaxBytes: ish.IntPtr(32_000),
OffloadDir: ".offload",
PreviewChars: ish.IntPtr(800),
},
AutoVirtualize: ish.BoolPtr(true),
VirtualizeThreshold: ish.IntPtr(600),
TombstoneObservations: ish.BoolPtr(true),
TombstoneThreshold: ish.IntPtr(150),
})
using Ish.Harness;
using var client = new IshClient();
var result = client.Run(new AgentRunRequest
{
Model = new AgentModel { Provider = "openai_chat", Name: "gpt-4o-mini" },
SystemPrompt = "Inspect logs and report the relevant findings.",
UserPrompt = "Review the latest logs.",
ContextOffload = new ContextOffloadOptions
{
MaxBytes = 32_000,
OffloadDirectory = ".offload",
PreviewChars = 800,
},
AutoVirtualize = true,
VirtualizeThreshold = 600,
TombstoneObservations = true,
TombstoneThreshold = 150,
});
import io.github.ishharness.IshClient;
import java.nio.file.Path;
try (var client = new IshClient(Path.of(System.getenv("ISH_NATIVE_LIBRARY")));
var request = new IshClient.AgentRequest(
"gpt-4o-mini",
"Inspect logs and report the relevant findings.",
"Review the latest logs.")
.provider("openai_chat")
.autoVirtualize(true)
.virtualizeThreshold(600)
.contextOffload(32_000, ".offload", 800)
.tombstoneObservations(true)
.tombstoneThreshold(150)) {
var result = client.runAgent(request);
System.out.println(result.path("content").asText());
}
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
| Need | Choose | Prompt impact |
|---|---|---|
| Keep full output on disk | File offload | Shows a short preview and file location |
| Let later tools use the full value | Virtualization | Shows a compact reference |
| Reduce older conversation content | Shorten old results | Replaces 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.