Fetch backtest logs
get_backtest_logsFetch runtime logs for an identified historical backtest simulation. This tool does not read live/paper bot or scheduled-deployment logs. Use get_deployment_logs for those runtime logs and list_deployment_artifacts/query_deployment_artifact for decisions, preserving the discovered deploymentId and runId. A deploymentId or deployment runId is not a backtestId. Use this, not get_backtest_artifact or query_csv, for backtest runtime errors, warnings, tracebacks, startup lines, order/fill log lines, broker messages, strategy print/log output, and questions like why a backtest failed or why it made no trades. backtestId must be the actual backtest run id from list_backtests or an explicit user-provided backtest id; never pass a strategy id, aiStrategyId, revisionId, browser URL revisionId, conversation id, or placeholder such as . Keep the same backtestId for every log/artifact/query call in one answer unless the user explicitly asks to compare multiple runs. Do not mix stats/trades/agent_detail/log evidence from different backtest ids. Supports time-range filtering (startTimeIso/endTimeIso), CloudWatch filter patterns (query), local multi-query diagnostics (queries), diagnosticPreset, noise suppression, pagination (nextToken), and grep-style context lines. Default limit is bounded; use limit near 1000 when diagnosing failures. For failed/no-trade/runtime-failure backtests, logs are mandatory evidence before editing code when logs are available. Prefer one batched queries call with at least three bounded searches: errors/exceptions/tracebacks, orders/trades/fills/positions, and strategy/runtime/main.py/on_trading_iteration lines. A single newest-first page or one warning line is not enough for root cause. For completed-backtest performance-improvement or tuning questions, this tool is also required evidence when logs are available; stats/trades/agent_detail queries do not replace runtime log checks. Use one batched queries call covering errors/exceptions, order/trade/fill/position activity, and strategy/runtime lines before final advice. diagnosticPreset values: broker_order_failure searches broker/order rejects, permission failures, and tracebacks; runtime_failure searches crashes, imports, dependency/build failures, kills, and exceptions; startup searches startup/stream/broker initialization; orders searches order/fill/cancel/reject activity; errors_and_warnings keeps error, critical and warning lines plus tracebacks; performance searches rate limits, retries, timeouts, cache/download/history lines and timing lines (use it after a slow backtest, together with backtest_status includeTiming=true). levels keeps only lines at the given log levels (for example ["ERROR","WARNING"]). For a failed run the response starts with failureSummary, one line saying what failed and why. Storage paths and cloud resource names are hidden from returned logs. Pass contextLines (0-50) with query, queries, or a preset to preserve surrounding lines. When contextLines, queries, diagnosticPreset, or noise suppression is set, the tool fetches one bounded raw CloudWatch window and filters locally so surrounding context is preserved. The response includes runtimeProvenance. It uses the exact run's structured settings.json.lumibot_version as the primary source, then the canonical bootstrap package-metadata line INFO: lumibot version: ... from the fetched raw CloudWatch window as a fallback or corroborating source. It reports conflicts instead of choosing one value, and preserves provenance even when the requested filtered log view omits the startup line. Treat runtimeProvenance.runtimeVersion as the installed runtime version only when its status is confirmed; a LumiBot source/reference version is not runtime evidence. The response also includes logs, perQuery match counts, totalLines, scannedLines, returnedLines, scannedStart/scannedEnd timestamps when visible, noiseSuppressedLines, truncatedQueryCount, nextToken, and paginationWarning when more pages may need checking. Broad queries are capped; if truncatedQueryCount is nonzero, run a narrower follow-up query. Do not substitute runtime log CSV artifacts.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"backtestId": "<backtestId>"
},
"name": "get_backtest_logs"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sort | No | ||
| limit | No | ||
| query | No | CloudWatch filter pattern when contextLines is omitted. For a case-insensitive JavaScript regex such as ERROR|Exception, set contextLines (0 means matching lines only), or use queries instead. | |
| levels | No | Keep only log lines at these levels, e.g. ["ERROR","WARNING"]. Matches the level word in the line prefix, not the same word inside a message. | |
| queries | No | Case-insensitive JavaScript regex searches applied locally to the fetched log page. | |
| nextToken | No | ||
| backtestId | Yes | Actual backtest run UUID for a historical simulation, from list_backtests or an explicitly identified user-provided backtest. A bot/deployment id or a list_deployment_runs runId is not a backtestId: use get_deployment_logs with that deploymentId instead. Do not use a strategy id, aiStrategyId, revisionId, browser URL revisionId, conversation id, or a placeholder such as <unknown>. | |
| endTimeIso | No | ||
| contextLines | No | Apply query locally as a regex and include this many surrounding lines. Zero returns matching lines only and still avoids CloudWatch filter syntax. | |
| startTimeIso | No | ||
| suppressNoise | No | ||
| diagnosticPreset | No |