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 src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ pub struct Agent<P: ModelProvider> {
pub omit_tools_field_when_empty: bool,
pub plan_tool_enforcement: PlanToolEnforcementMode,
pub mcp_pin_enforcement: McpPinEnforcementMode,
pub raw_tool_result_dir: Option<std::path::PathBuf>,
pub plan_step_constraints: Vec<PlanStepConstraint>,
pub current_plan: Vec<crate::tools::PlanItem>,
pub tool_call_budget: ToolCallBudget,
Expand Down
1 change: 1 addition & 0 deletions src/agent/gate_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ impl<P: ModelProvider> Agent<P> {
false,
crate::tools::ToolResultMeta {
side_effects: tool_side_effects(&tc.name),
duration_ms: None,
bytes: None,
exit_code: None,
stderr_truncated: None,
Expand Down
1 change: 1 addition & 0 deletions src/agent/timeouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl<P: ModelProvider> Agent<P> {
false,
ToolResultMeta {
side_effects: tool_side_effects(&tc.name),
duration_ms: Some(timeout_ms),
bytes: None,
exit_code: None,
stderr_truncated: None,
Expand Down
25 changes: 24 additions & 1 deletion src/agent/tool_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,29 @@ impl<P: ModelProvider> Agent<P> {
self.apply_update_plan_tool_success(&run_id, step, tc);
}
self.update_taint_for_tool_result(&run_id, step, tc, &content, messages.len(), taint_state);
let (model_tool_msg, artifact_warnings) =
crate::tools::to_model_observation_message_with_warnings(
&tool_msg,
tc,
&self.tool_rt.workdir,
self.raw_tool_result_dir.as_deref(),
);
for warning in artifact_warnings {
self.emit_event(
&run_id,
step,
EventKind::Error,
serde_json::json!({
"source": "tool_result_artifact",
"non_fatal": true,
"code": warning.code,
"warning": warning.message,
"path": warning.path,
"tool_call_id": tc.id,
"name": tc.name
}),
);
}
self.record_allowed_tool_result(
&run_id,
step,
Expand Down Expand Up @@ -1682,7 +1705,7 @@ impl<P: ModelProvider> Agent<P> {
failed_repeat_counts,
invalid_patch_format_attempts,
successful_write_tool_ok_this_step,
tool_msg,
model_tool_msg,
messages,
observed_tool_decisions,
);
Expand Down
1 change: 1 addition & 0 deletions src/agent_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ pub(crate) async fn run_agent_with_ui<P: ModelProvider>(
omit_tools_field_when_empty: false,
plan_tool_enforcement: effective_plan_tool_enforcement,
mcp_pin_enforcement: args.mcp_pin_enforcement,
raw_tool_result_dir: Some(paths.runs_dir.join(format!("{run_id}.tool-results"))),
plan_step_constraints,
current_plan: Vec::new(),
tool_call_budget: ToolCallBudget {
Expand Down
49 changes: 49 additions & 0 deletions src/agent_tests.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/agent_tool_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub(crate) async fn run_tool_once(
false,
ToolResultMeta {
side_effects: tool_side_effects(&tc.name),
duration_ms: None,
bytes: None,
exit_code: None,
stderr_truncated: None,
Expand All @@ -95,6 +96,7 @@ pub(crate) async fn run_tool_once(
false,
ToolResultMeta {
side_effects: tool_side_effects(&tc.name),
duration_ms: None,
bytes: None,
exit_code: None,
stderr_truncated: None,
Expand Down
19 changes: 19 additions & 0 deletions src/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,25 @@ pub(crate) struct DenyArgs {
#[derive(Debug, Subcommand)]

pub(crate) enum ReplaySubcommand {
Artifacts {
run_id: String,

#[arg(long, default_value_t = false)]
json: bool,
},

Artifact {
run_id: String,

artifact_ref: String,

#[arg(long, default_value_t = false)]
path_only: bool,

#[arg(long, default_value_t = false)]
json: bool,
},

Verify {
run_id: String,

Expand Down
51 changes: 43 additions & 8 deletions src/cli_dispatch_eval_replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,40 @@ pub(crate) async fn handle_replay_command(
paths: &store::StatePaths,
) -> anyhow::Result<()> {
match &args.command {
Some(ReplaySubcommand::Artifacts { run_id, json }) => {
let record = load_replay_run_record(paths, run_id)?;
let list = store::list_replay_artifacts(&paths.state_dir, &record)?;
if *json {
println!("{}", serde_json::to_string_pretty(&list)?);
} else {
print!("{}", store::render_replay_artifact_list(&list));
}
Ok(())
}
Some(ReplaySubcommand::Artifact {
run_id,
artifact_ref,
path_only,
json,
}) => {
let record = load_replay_run_record(paths, run_id)?;
let inspection =
store::inspect_replay_artifact(&paths.state_dir, &record, artifact_ref)?;
if *path_only {
println!("{}", inspection.summary.resolved_path);
} else if *json {
println!("{}", serde_json::to_string_pretty(&inspection)?);
} else {
print!("{}", store::render_replay_artifact_inspection(&inspection));
}
Ok(())
}
Some(ReplaySubcommand::Verify {
run_id,
strict,
json,
}) => {
let record = store::load_run_record(&paths.state_dir, run_id).map_err(|e| {
anyhow!(
"failed to load run '{}': {}. runs dir: {}",
run_id,
e,
paths.runs_dir.display()
)
})?;
let record = load_replay_run_record(paths, run_id)?;

let report = verify_run_record(&record, *strict)?;

Expand Down Expand Up @@ -95,6 +116,20 @@ pub(crate) async fn handle_replay_command(
}
}

fn load_replay_run_record(
paths: &store::StatePaths,
run_id: &str,
) -> anyhow::Result<store::RunRecord> {
store::load_run_record(&paths.state_dir, run_id).map_err(|e| {
anyhow!(
"failed to load run '{}': {}. runs dir: {}",
run_id,
e,
paths.runs_dir.display()
)
})
}

async fn resume_from_runtime_checkpoint(
checkpoint: &store::RuntimeRunCheckpointRecordV1,
paths: &store::StatePaths,
Expand Down
1 change: 1 addition & 0 deletions src/eval/runner_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ pub(crate) async fn run_single(
omit_tools_field_when_empty: false,
plan_tool_enforcement: crate::agent::PlanToolEnforcementMode::Off,
mcp_pin_enforcement: crate::agent::McpPinEnforcementMode::Hard,
raw_tool_result_dir: None,
plan_step_constraints: Vec::new(),
current_plan: Vec::new(),
tool_call_budget: ToolCallBudget {
Expand Down
3 changes: 3 additions & 0 deletions src/mcp/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ impl McpRegistry {
false,
ToolResultMeta {
side_effects: tool_side_effects(&tc.name),
duration_ms: None,
bytes: None,
exit_code: None,
stderr_truncated: None,
Expand Down Expand Up @@ -326,6 +327,7 @@ impl McpRegistry {
false,
ToolResultMeta {
side_effects: tool_side_effects(&tc.name),
duration_ms: Some(meta.elapsed_ms),
bytes: None,
exit_code: None,
stderr_truncated: None,
Expand Down Expand Up @@ -357,6 +359,7 @@ impl McpRegistry {
was_truncated,
ToolResultMeta {
side_effects: tool_side_effects(&tc.name),
duration_ms: Some(meta.elapsed_ms),
bytes: Some(result_str.len() as u64),
exit_code: None,
stderr_truncated: None,
Expand Down
7 changes: 7 additions & 0 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::{Path, PathBuf};

use crate::trust::policy::McpAllowSummary;

mod artifact_inspection;
mod hash;
mod io;
mod render;
Expand All @@ -12,6 +13,12 @@ pub use crate::agent_runtime::state::{
InterruptKindV1, PhaseSummaryEntryV1, RetryState, RunCheckpointV1 as RuntimeStateCheckpointV1,
RunPhase, ValidationState,
};
#[allow(unused_imports)]
pub use artifact_inspection::{
inspect_replay_artifact, list_replay_artifacts, render_replay_artifact_inspection,
render_replay_artifact_list, ReplayArtifactInspection, ReplayArtifactInspectionError,
ReplayArtifactList, ReplayArtifactRefSummary,
};
pub use hash::{
cli_trust_mode, config_hash_hex, hash_tool_schema, mcp_tool_snapshot_hash_hex,
provider_to_string, sha256_hex, stable_path_string, tool_schema_hash_hex_map,
Expand Down
Loading
Loading