feat: 优化运行时判定

This commit is contained in:
richarjiang
2026-09-24 14:27:07 +08:00
parent dfd3998399
commit f0ac603f27
25 changed files with 2368 additions and 58 deletions

View File

@@ -1,15 +1,20 @@
"""Routing questions sent to Laya in one forward pass.
``choice`` is used for task level because Laya's ordinal ``score`` primitive is
the weakest of the three. Bump ``QUESTIONS_VERSION`` when the wording changes
the weakest of the three. Bump the matching version when the wording changes
so logged decisions stay interpretable.
"""
from __future__ import annotations
QUESTIONS_VERSION = "1"
POST_TOOL_VERSION = "1"
PRE_EDIT_VERSION = "1"
GATE_VERSION = "1"
STOP_VERSION = "1"
SKILL_VERSION = "1"
QUESTIONS: dict = {
PROMPT_QUESTIONS: dict = {
"task_level": {
"type": "choice",
"instructions": (
@@ -59,3 +64,80 @@ QUESTIONS: dict = {
),
},
}
POST_TOOL_QUESTIONS: dict = {
"is_stuck": {
"type": "noul",
"instructions": (
"Is the coding agent stuck: repeating itself, looping on the same "
"error, or making no progress on the user's request?"
),
},
"should_replan": {
"type": "noul",
"instructions": (
"Should the coding agent stop editing and make a new plan before "
"the next change?"
),
},
"needs_more_context": {
"type": "noul",
"instructions": (
"Does the agent need to read more of the repository before it can "
"safely continue?"
),
},
}
PRE_EDIT_QUESTIONS: dict = {
"edit_premature": {
"type": "noul",
"instructions": (
"Is the agent about to edit code it has not understood yet, without "
"reading the relevant file or its callers?"
),
},
}
GATE_QUESTIONS: dict = {
"destructive": {
"type": "noul",
"instructions": (
"Would this tool call delete data, overwrite unrelated files, wipe "
"history, or otherwise destroy work?"
),
},
"irreversible": {
"type": "noul",
"instructions": (
"Is this tool call hard to undo, such as a force push, a published "
"release, dropping a database, or sending a message?"
),
},
"touches_secrets_or_prod": {
"type": "noul",
"instructions": (
"Does this tool call read or write secrets, credentials, production "
"configuration, or a production system?"
),
},
}
STOP_QUESTIONS: dict = {
"claims_done_without_verification": {
"type": "noul",
"instructions": (
"Is the agent claiming the task is finished even though the edited "
"code has not been verified by a test, build, or typecheck?"
),
},
"task_incomplete": {
"type": "noul",
"instructions": (
"Is the user's request still unfinished in the work shown here?"
),
},
}
# Backward-compatible alias used by the prompt route and the warmup call.
QUESTIONS: dict = PROMPT_QUESTIONS