Repository navigation
investigate: answer command for AI sessions, parent_run on starts - #486
Conversation
…layed flush Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
/lc-review |
|
Self-review (adversarial), as the author:
|
There was a problem hiding this comment.
AI Code Review Summary
Verdict: APPROVED (0 High, 0 Medium, 3 Low)
I found no High or Medium issues. Secret handling looks right. redact_body is passed from Investigation._call through Client.request and _rest_call to both debug paths. The token is sent only in the JSON body, never in the URL or query. The SDK and CLI errors are built from the API response, refused input, or variable names, never from the token value. test_debug_logging.TestRedactBody checks the real _rest_call debug output.
General Feedback
- No
test-time-budgetcheck run was found for this commit. The base branchmasterdoes not require it (branch protection and rulesets list no such check), and this PR does not change any workflow. - Note (not counted): the PR body and docs say the answer is "sent once and never retried". In practice,
Client.requestcan still send the same body again after a 401 (JWT refresh) or a 429 (when quota retries are on). The server refused both of those before recording anything, so the guarantee still holds for the engine. The wording is just slightly broader than the code.
Blast radius
Client.request/_rest_call/_debug_request/_debug_curl_cmdgain an optionalredact_bodykeyword, defaultFalse. Existing callers are unaffected. Code that subclassesClientand overrides these methods with the old signature would get aTypeErrorwhen the new SDK call passesredact_body.InvestigationError.to_dict()now addsfieldswhenever an engine error body has a non-emptyfieldsdict. This applies to everyinvestigatecommand's structured error output, not justanswer.investigate runs startnow sendsparent_runwheneverLC_IE_RUN_IDis set in the environment. A script that inherits that variable will have its starts treated as agent-made (no AI agent steps). Direct SDK users ofstart_rundo not get this guard.investigate queue flushchanges its stderr note forreplayed: trueanswers. The stdout document is unchanged.
This review was generated automatically by Claude Code.
…gs, full-path debug test) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
/lc-review |
There was a problem hiding this comment.
AI Code Review Summary
Verdict: APPROVED (0 High, 0 Medium, 0 Low)
Re-review of the commits since dd187c8. Five files changed: the doc, commands/investigate.py, sdk/investigation.py and both test modules. The other files are unchanged since my last review. All three earlier Low findings are fixed (see the thread replies). The new code is correct: a blank --run-id/--request-id/--token is now refused, not replaced by the environment value. A 404 with no engine code now gets the route hint. The new SDK test runs a real Client with urlopen patched and all debug modes on, so it covers the whole redaction path.
General Feedback
- Note (carried over, not counted): the
submit_agent_answerdocstring now says the call is replayed "only after a 401 token refresh".Client.requestalso resends the same body after a 429 when the client was built withis_retry_quota_errors=True. The server refused that request before it recorded anything, so the one-answer guarantee still holds. Only the wording is narrower than the code. - No
test-time-budgetcheck run was found for this commit.masterdoes not require the check (branch protection and rulesets list none), and this PR does not change any workflow.
Blast radius
This is the same as the last review. Client.request/_rest_call/debug helpers gain an optional redact_body keyword (default False). InvestigationError.to_dict() adds fields for every investigate command. runs start sends parent_run whenever LC_IE_RUN_ID is set. The new answer command now refuses blank flag values with exit code 2.
This review was generated automatically by Claude Code.
…de-less 403 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
/lc-review |
There was a problem hiding this comment.
AI Code Review Summary
Verdict: APPROVED (0 High, 0 Medium, 0 Low)
Re-review of the commits since 11f9da9. Only limacharlie/sdk/investigation.py and tests/unit/test_sdk_investigation.py changed. The other PR files are unchanged since my last review. My three earlier findings were already confirmed fixed in their threads.
The new code is correct:
submit_agent_answernow serializes the answer withallow_nan=Falseand refuses an answer that contains the token before any request is sent. The error message does not repeat the token. The test checks this through the real SDK method, and checks thatclient.requestis never called.- The 403 message with no engine code now also mentions a missing key id. A new parametrized case covers it.
General Feedback
- Note (carried over, not counted): the docstring says the call is replayed "only after a 401 token refresh".
Client.requestalso resends after a 429 whenis_retry_quota_errors=True. The server refused that request before recording anything, so only the wording is off. - Note (not counted): the token-in-answer check matches against
json.dumpsoutput, which usesensure_ascii=True. A token with non-ASCII,"or\characters would be escaped there and not match. Engine tokens are presumably URL-safe ASCII, so this does not matter in practice. - No
test-time-budgetcheck run was found for this commit.masterdoes not require the check (branch protection and rulesets list none), and this PR does not change any workflow.
Blast radius
Same as the last review, plus one change. Client.request, _rest_call and the debug helpers gain an optional redact_body keyword (default False). InvestigationError.to_dict() adds fields for every investigate command. runs start sends parent_run whenever LC_IE_RUN_ID is set. New: Investigation.submit_agent_answer now raises ValidationError for answers that are not JSON-safe or that contain the token. This affects SDK callers as well as the CLI.
This review was generated automatically by Claude Code.
|
Review round 1 threads: the ambient LC_IE_RUN_ID is now cleared for every test in the module (autouse fixture); the vacuous debug test was dropped and replaced by a test through a real Client with every debug mode on; the wording no longer promises |
What
The command an Investigation Engine AI session uses to answer the
ai_agentstep that started it, and the loop guard on starts the session makes.limacharlie investigate answer (--answer JSON | --answer-file PATH|-): the run, request and one-time answer token default fromLC_IE_RUN_ID,LC_IE_REQUEST_ID,LC_IE_ANSWER_TOKEN(flags--run-id,--request-id,--tokenoverride). SDK:Investigation.submit_agent_answer()(POST investigate/{oid}/runs/{run_id}/agent-answers/{request_id}, body{token, answer}, sent once, never retried).--help, and not in--debug/--debug-curloutput:Client.request()gainsredact_body, which replaces the request body in both debug paths. Tests cover the wire path (a real_rest_callwith a captured log), the CLI and the SDK.AGENT_ANSWER_MEANINGS, shown as the error's suggestion): 400invalid_answer(every field and why, kept in the machine-readable document asfields; nothing was recorded, fix and resend before the deadline), 403forbidden(wrong token; a 403 with no code is a missinginvestigation.get), 404not_found, 409already_answered/deadline_passed/not_waiting(too late), 501not_implemented.investigate runs startsendsparent_run(fromLC_IE_RUN_ID) when set, so a run an agent starts asks no further agent.nullforoldest_enqueued_atandhour.runs_per_hour, a person's start is aby_rulerow with norulekey,hour.start_failedexists, and a repeated flush is answered withreplayed: true. The commands already printed all of these; the one defect wasqueue flushsaying "Flushed N" for a replayed answer, which flushed nothing itself. It now says so. Docs and docstrings describe the real shapes, and tests use the engine's documented answers (empty queue, person's start, replayed flush, flush still running) in json, table and yaml.Docs:
doc/cli/investigation-engine.md(new "AI agent answers" section, runs, queue),--explaintext,investigation_enginediscovery profile, CHANGELOG (Unreleased). No release, no publish.Tests
pytest tests/unit/ tests/microbenchmarks/: 6754 passed (151 skipped, all pre-existing).Self-review (adversarial)
--debug,--debug-curl, argv logging (cli.pyreadssys.argvonly for the--debugflag), error documents,--helpwith the variable set, invalid-id errors, usage errors for a missing value (name the variable, never a value).--tokenis the user's choice and stays in shell history: said in the help and the docs.parent_runis read from the environment only; there is deliberately no flag to drop it.invalid_answer; the CLI does not pre-check the size.🤖 Generated with Claude Code