Repository navigation
Description
Agents that run conversations for a user (for example OpenHands Projects, #6602) need to know when a turn leaves nothing for the user: no question to answer, no PR to review, no choice to make. That is a different question from the critic's "did the task succeed?".
Proposed, in the SDK:
- A judge that asks a model narrow yes/no questions about the turn (via
DecisionModel, already on main) and combines the answers in code into a verdict: resolved, or what the user still owes (answer,review,decide,check, ...). - Its model is a saved LLM profile named
resolution_judge, resolved by convention likeoracleandcleanup. If the profile does not exist, it is created on first use as a copy of the conversation's own LLM, so users can find it with their other profiles and point it at another model. - No environment-variable configuration and no text heuristics: the model decides.
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
SDK-only feature following the repository's profile-by-convention precedents: openhands-sdk/openhands/sdk/llm/cleanup_profile.py (stateless standalone module whose model is a saved profile resolved by convention through LLMProfileStore) and the ask_oracle tool (profile looked up from the conversation's profile store). The judge asks typed yes/no (Noul) questions through DecisionModel (openhands-sdk/openhands/sdk/llm/decision.py, public on main) and combines the answers in code into a verdict.
Scope decisions taken from repository evidence and the issue's own stated choices:
- The judge is a standalone SDK callable that a caller invokes after a turn with that turn's events; it is not auto-run by
Conversation.run(), not an agent tool, and has no agent-server REST/WebSocket surface. - On first use with no saved profile, the judge creates the
resolution_judgeprofile inLLMProfileStoreas a copy of the conversation's own LLM. This is the issue's explicit product choice and intentionally differs fromoracle(which surfaces an error when the profile is missing) andcleanup(which fails open and does nothing). - The initial set of owed categories is exactly the four named in the issue (
answer,review,decide,check); extending the set later is a compatible addition and is not part of this work. - The issue defines no fail-open verdict, so when the decision call fails after
DecisionModelretries, the mapped SDK LLM error propagates to the caller instead of returning a default verdict.
Non-goals: scoring whether the task succeeded (that stays with the critic); persisting judge results as events or in settings schemas; environment-variable configuration for the judge's model; text-pattern heuristics; consumption by OpenHands Projects (#6602) in OpenHands/OpenHands; changes to the agent server or clients/typescript/.
Acceptance Criteria
- Calling the judge on a turn whose events leave nothing for the user (no question asked, no PR opened for review, no choice offered, no unverifiable result) returns the
resolvedverdict, verified by a test with a constructed event sequence. - For turns ending respectively with (a) a direct question to the user, (b) a PR or diff awaiting user review, (c) a choice the user must make, and (d) a result the agent could not verify itself, the judge returns
answer,review,decide, andcheck; each case has its own test. - The verdict is computed in code from the typed
DecisionResultanswers, not from model-generated prose; a test asserts the mapping from answers to verdict. - The verdict is a serializable SDK type whose values are exactly
resolvedplusanswer,review,decide,checkin this cut, and it round-trips throughmodel_dump/model_validate. - First use when no
resolution_judgeprofile is saved creates one inLLMProfileStoreas a copy of the conversation's own LLM: a test assertsLLMProfileStore.load("resolution_judge")afterwards returns a profile with the conversation LLM's model and connection configuration. - Once the profile exists, editing the saved
resolution_judgeprofile changes the model the judge uses on its next call; a test asserts the judge uses the edited profile's model. - Profile creation and loading go through
LLMProfileStore(including its cipher/secret handling); the judge introduces no environment-variable configuration and no text-pattern heuristics. - If the decision call fails after
DecisionModelretries, the judge raises the mapped SDK LLM error rather than returning a default verdict; a test overridesDecisionModel.sendto raise and asserts propagation. - Sync and async entry points both exist, matching the
cleanupmodule convention. - Tests live under
tests/sdk/mirroring the new module path and pass withuv run pyteston the smallest relevant set. - Documentation for the new public API is added in the
OpenHands/docsrepository undersdk/, per the SDK documentation workflow, alongside the change.
Activity