MCPcopy Create free account
hub / github.com/AI45Lab/Code / merge_tool_output_artifact_metadata

Function merge_tool_output_artifact_metadata

core/src/tools/mod.rs:132–156  ·  view source on GitHub ↗
(
    metadata: Option<serde_json::Value>,
    artifact: &ToolOutputArtifact,
)

Source from the content-addressed store, hash-verified

130}
131
132pub(crate) fn merge_tool_output_artifact_metadata(
133 metadata: Option<serde_json::Value>,
134 artifact: &ToolOutputArtifact,
135) -> serde_json::Value {
136 let artifact_json = serde_json::json!({
137 "artifact_id": artifact.artifact_id,
138 "artifact_uri": artifact.artifact_uri,
139 "original_bytes": artifact.original_bytes,
140 "shown_bytes": artifact.shown_bytes,
141 });
142
143 match metadata {
144 Some(serde_json::Value::Object(mut object)) => {
145 object.insert("artifact".to_string(), artifact_json);
146 serde_json::Value::Object(object)
147 }
148 Some(value) => serde_json::json!({
149 "artifact": artifact_json,
150 "previous_metadata": value,
151 }),
152 None => serde_json::json!({
153 "artifact": artifact_json,
154 }),
155 }
156}
157
158/// Tool execution result returned by direct tool execution.
159#[derive(Debug, Clone, Serialize, Deserialize)]

Callers 2

execute_with_contextMethod · 0.85

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected