MCPcopy Create free account
hub / github.com/diillson/chatcli / buildSessionWorkspaceHint

Function buildSessionWorkspaceHint

cli/agent_mode.go:3229–3267  ·  view source on GitHub ↗

model how to use the per-session scratch dir and how to recover data from truncated tool results. Returns an empty string when the session workspace hasn't been initialized (shouldn't happen during normal startup).

()

Source from the content-addressed store, hash-verified

3227// truncated tool results. Returns an empty string when the session workspace
3228// hasn't been initialized (shouldn't happen during normal startup).
3229func buildSessionWorkspaceHint() string {
3230 ws := agent.GetSessionWorkspace()
3231 if ws == nil {
3232 return ""
3233 }
3234 return "\n\n## SESSION WORKSPACE & LARGE OUTPUTS\n" +
3235 "\n" +
3236 "You have an isolated scratch directory for this session, exposed via the\n" +
3237 "environment variable `CHATCLI_AGENT_TMPDIR` (current value: `" + ws.ScratchDir + "`).\n" +
3238 "Both read and write are ALLOWED in this directory and in its subtree —\n" +
3239 "use it whenever you need to:\n" +
3240 "- stage a temporary shell script before exec'ing it;\n" +
3241 "- persist an intermediate artifact between tool calls;\n" +
3242 "- avoid polluting the project tree with one-off files.\n" +
3243 "\n" +
3244 "Example: `exec { \"cmd\": \"cat > $CHATCLI_AGENT_TMPDIR/patch.sh <<'EOF' ...\" }`.\n" +
3245 "\n" +
3246 "### Truncated tool outputs\n" +
3247 "\n" +
3248 "When a tool result is large, ChatCLI automatically truncates it inline\n" +
3249 "and saves the FULL output to a file in this session. You will see a\n" +
3250 "marker like:\n" +
3251 "\n" +
3252 " ... [N chars omitted — full output saved to /tmp/chatcli-agent-XXX/tool-results/budget_xxx.txt]\n" +
3253 " ... [full output saved to /tmp/chatcli-agent-XXX/tool-results/result_XXX.txt — N bytes total]\n" +
3254 "\n" +
3255 "When you see such a marker and the omitted portion matters, use the\n" +
3256 "`read_file` tool with `start` / `end` line numbers to examine specific\n" +
3257 "ranges of the saved file — do NOT re-run the original tool call.\n" +
3258 "\n" +
3259 "### Delegating heavy analysis\n" +
3260 "\n" +
3261 "For tasks that would otherwise flood your context with raw data (large\n" +
3262 "metrics endpoints, verbose logs, wide-scope searches), use the\n" +
3263 "`delegate_subagent` tool. The subagent runs with its OWN isolated\n" +
3264 "context window; only its final summary returns to you. Example use\n" +
3265 "cases: \"summarize memory hotspots from /metrics\", \"find all call\n" +
3266 "sites of func X across the repo\".\n"
3267}
3268
3269// isDelegateInvocation reports whether an @coder JSON args payload is a
3270// delegate_subagent call rather than a normal engine subcommand.

Callers 1

RunMethod · 0.85

Calls 1

GetSessionWorkspaceFunction · 0.92

Tested by

no test coverage detected