Server-side helpers for drafting acceptance criteria from goal objectives.
Default model-node retry attempts after the first call when config is absent.
Canonical source for the dcode retry default; model_retry re-exports it so the
middleware and the config resolver never drift.
Maximum combined raw characters in an accepted objective and its criteria.
Published to the criteria model and enforced per field on raw text, so it stays
comparable to the per-field max_length values the schema publishes. The
rendered budget — what an accepted pair is allowed to occupy after HTML
escaping — is GOAL_NOTICE_TEXT_CHAR_LIMIT, which is wider.
Maximum characters in one persisted goal objective.
Maximum characters in one rubric or goal acceptance-criteria value.
Validate an objective and its generated criteria as one application.
Validate only the combined budget, not either field's own limit.
Split out because the two kinds of overshoot need opposite handling in the
criteria agent's structured-output loop: a per-field overshoot is a model
mistake against a limit the schema publishes, so it is worth retrying, while
the combined budget is not in the schema at all and half of it is the user's
own objective. See _raise_terminal_goal_state_size_error.
Reject a goal objective that cannot fit its persistent context budget.
This checks raw length only. HTML escaping can still expand the text
fivefold, so a caller about to run criteria generation should also call
validate_goal_objective_rendered: an objective that passes here can still
leave no room for any criteria in the rendered notice.
Reject criteria that cannot fit their persistent context budget.
Return whether a message should be omitted from derived transcripts.
Create the ephemeral server-side criteria agent graph.
Create the goal-only fallback agent for criteria generation.
This agent has no context tools, repository access, or HITL: it drafts
acceptance criteria from the goal message alone. GoalCriteriaMiddleware
invokes it when the context-enabled agent fails at the graph level (e.g.
exhausts its recursion budget) or returns no usable proposal, restoring the
guarantee that /goal always yields criteria unless the model itself is
unavailable.
Path-safety and size limits for read-only repository inspection tools.
Goal/rubric text exceeds a model-visible context budget.
Extends agent state with per-checkpoint facts restored on resume.
Inherits the shared goal/rubric channels from GoalRubricChannels and adds
the channels unique to resume: the after-model token/spec facts and the
pending-goal proposal awaiting acceptance.
Structured proposal returned by the criteria agent.
A new proposal or a rejection-based regeneration.
feedback/previous_criteria are only present on a rejection retry.
An amendment to an accepted goal; both extra fields are required.
Main-agent state carrying a criteria request until it is cleared.
This intentionally uses normal last-value state: earlier middleware can
consume an ephemeral channel before GoalCriteriaMiddleware runs. Success
clears the request here, while the TUI uses a request-correlated checkpoint
update after failure or cancellation. Normal TUI and headless turns also
submit None defensively so a terminal request can never rerun as chat.
Private per-invocation state for the nested criteria agent.
Nested-grader state used to scope verification-tool budgets.
Run goal-criteria requests entirely inside the main server graph.