Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/xgen-cli/src/composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ const fn proposal_rejection_code(rejection: ProposalRejection) -> &'static str {
"proposal_rejected.invocation_invalid"
}
ProposalRejection::DuplicateSemanticAction => "proposal_rejected.duplicate_semantic_action",
ProposalRejection::RepeatedFinishedAction => "proposal_rejected.repeated_finished_action",
ProposalRejection::PlannedStepBudgetExceeded => {
"proposal_rejected.planned_step_budget_exceeded"
}
Expand Down
24 changes: 21 additions & 3 deletions crates/xgen-cli/tests/interactive_repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,28 @@ fn one_invalid_response_is_retried_and_the_run_completes_without_resume() {
.unwrap();
assert_eq!(output.status.code(), Some(0), "{}", stderr(&output));
// plan, discarded invalid completion, accepted completion
for _ in 0..3 {
server.requests.recv_timeout(TEST_TIMEOUT).unwrap();
}
let requests: Vec<_> = (0..3)
.map(|_| server.requests.recv_timeout(TEST_TIMEOUT).unwrap())
.collect();
server.handle.join().unwrap();
// ADR-0064: only the call after the discarded response learns why it was discarded.
assert!(
planning_context(&requests[1])
.get("previousResponseRejection")
.is_none()
);
let rejection = &planning_context(&requests[2])["previousResponseRejection"];
assert_eq!(
rejection["reason"], "planner_invalid_response",
"{rejection}"
);
assert!(rejection.get("proposalRejection").is_none());
assert!(
rejection["meaning"]
.as_str()
.unwrap()
.starts_with("The previous response was discarded")
);
assert!(
!stderr(&output).contains("model_rejected"),
"{}",
Expand Down
6 changes: 5 additions & 1 deletion crates/xgen-cli/tests/live_go50902_public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,11 @@ fn require_workspace_completion(output: &Output, state_root: &Path) {
}
if let Some(reason) = snapshot.records.iter().rev().find_map(|record| {
if let RunEventBody::ModelCallSettled {
settlement: ModelCallSettlement::Rejected { reason },
settlement:
ModelCallSettlement::Rejected {
reason,
proposal: None,
},
..
} = record.event.body
{
Expand Down
17 changes: 14 additions & 3 deletions crates/xgen-cli/tests/workspace_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1824,12 +1824,17 @@ fn tool_discovery_is_approved_receipted_and_frozen_across_resume() {
#[test]
#[cfg(unix)]
fn tool_discovery_rejects_unknown_collections_and_candidate_execution() {
for (capability_id, input) in [
for (capability_id, input, code) in [
(
"xgen.tools/search",
json!({"collection":"unknown","query":"record","topK":1}),
"invocation_invalid",
),
(
"readAsset",
json!({"asset_id":"one"}),
"capability_unavailable",
),
("readAsset", json!({"asset_id":"one"})),
] {
let fixture = tempdir().unwrap();
let state = fixture.path().join("state");
Expand Down Expand Up @@ -1873,8 +1878,14 @@ fn tool_discovery_rejects_unknown_collections_and_candidate_execution() {
.unwrap();
assert!(store.load_execution_receipts().unwrap().is_empty());
assert!(!state.join("tool-collections/invocations").exists());
server.requests.recv_timeout(TEST_TIMEOUT).unwrap();
let requests: Vec<_> = (0..=xgen_cli::MAX_REJECTED_RESPONSE_RETRIES)
.map(|_| server.requests.recv_timeout(TEST_TIMEOUT).unwrap())
.collect();
server.handle.join().unwrap();
// ADR-0064: each retry carries the Core class of the rejection before it.
let rejection = &planning_context(&requests[1])["previousResponseRejection"];
assert_eq!(rejection["reason"], "proposal_rejected", "{rejection}");
assert_eq!(rejection["proposalRejection"], code, "{rejection}");
}
}

Expand Down
4 changes: 3 additions & 1 deletion crates/xgen-provider-openai/tests/http_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ fn completed_output_store() -> (OutputSnapshotStore, AgentLoopBudget, Value) {
settled_calls: 1,
unknown_calls: 0,
active_call: None,
last_rejection: None,
}),
completion_candidate: None,
}),
Expand Down Expand Up @@ -1147,7 +1148,8 @@ fn deterministic_provider_rejection_is_closed_without_raw_error_body() {
&last.event.body,
RunEventBody::ModelCallSettled {
settlement: ModelCallSettlement::Rejected {
reason: ModelCallRejectionReason::ProviderRejected
reason: ModelCallRejectionReason::ProviderRejected,
proposal: None,
},
..
}
Expand Down
Loading