Skip to content

Context Management

tradesdontlie edited this page Jul 21, 2026 · 1 revision

Context Management

These tools can return large payloads. An agent working a long task needs to keep its context window lean, or it burns tokens and slows down. This page is the discipline that keeps responses small. Most of it is baked into the project's CLAUDE.md so agents follow it automatically.

The eight rules

  1. Always use summary: true on data_get_ohlcv unless you specifically need individual bars.
  2. Always use study_filter on the Pine graphics tools when you know which indicator you want — don't scan every study.
  3. Never use verbose: true on Pine tools unless the user explicitly asks for raw drawing data (IDs, colors, coordinates).
  4. Avoid pine_get_source on complex scripts — it can return 200KB+. Only read it if you need to edit the code.
  5. Avoid data_get_indicator on protected/encrypted indicators — their inputs are encoded blobs. Use data_get_study_values for current values instead.
  6. Prefer capture_screenshot for visual context over pulling large datasets — it returns a file path (~300 bytes), not image bytes, yet captures the full picture.
  7. Call chart_get_state once at the start to grab entity IDs, then reference them — don't re-call it repeatedly.
  8. Cap OHLCV requestscount: 20 for a quick look, count: 100 for deeper work, count: 500 only when truly needed.

Output size cheat sheet (compact mode)

Tool Typical output
quote_get ~200 bytes
data_get_study_values ~500 bytes (all indicators)
data_get_pine_lines ~1–3 KB per study (deduplicated levels)
data_get_pine_labels ~2–5 KB per study (capped at 50)
data_get_pine_tables ~1–4 KB per study (formatted rows)
data_get_pine_boxes ~1–2 KB per study (deduplicated zones)
data_get_ohlcv (summary) ~500 bytes
data_get_ohlcv (100 bars) ~8 KB
capture_screenshot ~300 bytes (returns file path, not image data)

Hard caps to know

  • OHLCV is capped at 500 bars per request.
  • Trades (data_get_trades) capped at 20 per request.
  • Pine labels capped at 50 per study by default — pass max_labels to override.

The mental model

Read the smallest thing that answers the question. A screenshot beats a data dump for "how does this look." A summary: true OHLCV beats 500 raw bars for "what's the trend." A study_filtered Pine call beats scanning every study for "what does the Profiler show."

When in doubt, reach for the compact form first — you can always pull the detailed version if the summary isn't enough.


See also: Agent Workflows · Reading Custom Pine Output · Tool Reference.

Clone this wiki locally