Skip to content

Commit 28ba625

Browse files
swjnxyfyyjeqhc
andauthored
perf(runtime): reduce model-facing status and discovery cost (#695)
Co-authored-by: yyjeqhc <1772413353@qq.com>
1 parent d7c6470 commit 28ba625

30 files changed

Lines changed: 1326 additions & 777 deletions

‎crates/webcodex-tool-contracts/src/registry/output_schemas/discovery.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ pub(super) fn output_schema_for_tool(name: &str) -> Option<Value> {
2727
("truncated", schema_type("boolean", "Visible events from the bounded recent scan were omitted by the presentation or serialized byte bound; this is not a lifetime-history completeness claim.")),
2828
])),
2929
"runtime_status" => Some(wrapped_output_schema(vec![
30+
("mcp_host", open_object_schema("Sparse status: effective MCP Host profile.")),
31+
("compatibility", open_object_schema("Sparse fleet protocol, build/source alignment and mixed-build evidence; no per-Runner rows.")),
32+
("connection", open_object_schema("Sparse process, transport and Project registry states without timestamps.")),
33+
3034
("service", schema_type("string", "Runtime service name.")),
3135
(
3236
"mcp_compact_schemas",
@@ -104,11 +108,11 @@ pub(super) fn output_schema_for_tool(name: &str) -> Option<Value> {
104108
),
105109
(
106110
"projects",
107-
open_object_schema("Project counts from the Runner registry. Prefer projects.effective for model-facing status."),
111+
open_object_schema("Project counts from the Runner registry; sparse returns count, online_count and status. Full includes effective and runner_registered."),
108112
),
109113
(
110114
"runners",
111-
open_object_schema("Runner counts and a single clients collection using runner_instance_id and runner_protocol_generation; summary contains only aggregate counts. Omitted in focused compact/summary mode. Per-client host_context is bounded Runner-configured advisory data, not observed truth or authority. job_concurrency contains the static Runner limit plus caller-visible running and queued counts. Canonical top-level counts are count, online_count, and stale_count in full, compact, and summary_only output."),
115+
open_object_schema("Sparse fleet returns aggregate counts only. Full includes a single clients collection using runner_instance_id and runner_protocol_generation; summary contains only aggregate counts. Omitted in focused compact/summary mode. Per-client host_context is bounded Runner-configured advisory data, not observed truth or authority. job_concurrency contains the static Runner limit plus caller-visible running and queued counts. Canonical top-level counts are count, online_count, and stale_count in full, compact, and summary_only output."),
112116
),
113117
(
114118
"jobs",

‎crates/webcodex-tool-contracts/src/registry/tool_specs.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,16 @@ mod tests {
448448
assert!(work_on_project.contains("mode=worktree"));
449449
assert!(work_on_project.contains("exact Git base"));
450450
assert!(work_on_project.contains("Project authority"));
451-
for name in ["list_runners", "runtime_status"] {
451+
let status = &find("runtime_status").description;
452+
for hint in [
453+
"Job concurrency",
454+
"sparse",
455+
"full diagnostics",
456+
"compact=false",
457+
] {
458+
assert!(status.contains(hint), "runtime_status: {status}");
459+
}
460+
for name in ["list_runners"] {
452461
let description = &find(name).description;
453462
assert!(
454463
description.contains("shared Job concurrency"),

‎crates/webcodex-tool-contracts/src/tests/definitions.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ fn stop_job_direct_exposure_preserves_one_canonical_effect_and_gateway_budget()
633633
.count(),
634634
1
635635
);
636-
assert_eq!(definition.adaptive_runtime_direct_rank(), Some(81));
636+
assert_eq!(definition.adaptive_runtime_direct_rank(), None);
637637
assert_eq!(
638638
definition.gpt_action_exposure(),
639639
ToolGptActionExposure::GatewayOnly
@@ -774,12 +774,9 @@ fn adaptive_runtime_direct_declarations_are_visible_ranked_and_unique() {
774774
("rotate_agent_continuation_endpoint", 19),
775775
("import_conversation_files_to_project", 55),
776776
("project_artifact", 56),
777-
("transfer_project_artifact", 57),
778-
("run_detached_process", 72),
779777
("run_script", 74),
780778
("run_shell", 75),
781779
("observe_jobs", 80),
782-
("stop_job", 81),
783780
] {
784781
let definition = derived
785782
.iter()
@@ -793,6 +790,10 @@ fn adaptive_runtime_direct_declarations_are_visible_ranked_and_unique() {
793790
}
794791

795792
for name in [
793+
"list_jobs",
794+
"stop_job",
795+
"run_detached_process",
796+
"transfer_project_artifact",
796797
"workspace_hygiene_check",
797798
"finish_coding_task",
798799
"runner_config_check",
@@ -823,7 +824,6 @@ fn adaptive_runtime_direct_declarations_are_visible_ranked_and_unique() {
823824

824825
for (name, expected_rank, expected_authority) in [
825826
("session_discussion_summary", 15, RUNTIME_READ),
826-
("list_jobs", 85, RUNTIME_READ),
827827
("git_diff_hunks", 125, PROJECT_READ),
828828
] {
829829
let definition = derived

‎crates/webcodex-tool-contracts/src/tool_call.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5027,8 +5027,8 @@ pub enum ToolCall {
50275027
/// secrets, full env, or stdout/stderr. It returns service metadata,
50285028
/// Project config status, Runner summaries, and Job counts.
50295029
RuntimeStatus {
5030-
/// When true, return compact runtime observability with service/version, build revision, tool/job
5031-
/// counts, Runner health summary, and project effective/server status. Defaults to false.
5030+
/// True selects sparse health, Project/Job counts and protocol/build/source alignment without
5031+
/// inventories. Canonical/API default is false (full diagnostics); MCP defaults omission to true.
50325032
#[serde(default)]
50335033
compact: bool,
50345034
/// Alias for compact=true. Returns the same compact runtime observability shape. Defaults to false.

‎crates/webcodex-tool-contracts/src/tool_definition/artifacts.rs‎

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,34 @@ pub(super) const DEFINITIONS: &[ToolDefinition] = &[
6767
),
6868
55,
6969
),
70-
adaptive_runtime_direct(
71-
permission_risk(
72-
model_spec(
73-
require_all_scopes(
74-
def(
75-
"transfer_project_artifact",
76-
super::ToolAuditPolicy::TYPED_CANONICAL,
77-
ModelVisible,
78-
TOOL_CATEGORY_ARTIFACT,
79-
None,
80-
TOOL_PROVIDER_CONTROL,
81-
super::ToolSemanticContract {
82-
effect: super::ToolEffect::Mutate,
83-
risk: ProjectWrite,
84-
approval: super::ToolApprovalPolicy::Standard,
85-
idempotency: super::ToolIdempotency::NonIdempotent,
86-
},
87-
None,
88-
false,
89-
Artifact,
90-
true,
91-
false,
92-
super::ToolSessionEvidencePolicy::NONE,
93-
),
94-
&[PROJECT_READ, PROJECT_WRITE],
70+
permission_risk(
71+
model_spec(
72+
require_all_scopes(
73+
def(
74+
"transfer_project_artifact",
75+
super::ToolAuditPolicy::TYPED_CANONICAL,
76+
ModelVisible,
77+
TOOL_CATEGORY_ARTIFACT,
78+
None,
79+
TOOL_PROVIDER_CONTROL,
80+
super::ToolSemanticContract {
81+
effect: super::ToolEffect::Mutate,
82+
risk: ProjectWrite,
83+
approval: super::ToolApprovalPolicy::Standard,
84+
idempotency: super::ToolIdempotency::NonIdempotent,
85+
},
86+
None,
87+
false,
88+
Artifact,
89+
true,
90+
false,
91+
super::ToolSessionEvidencePolicy::NONE,
9592
),
96-
"Transfer one regular artifact directly from a source Project to a destination Project through Control. Requires source project:read and destination project:write; each Project is independently resolved and authorized. Control fences the exact source bytes/SHA-256/MIME snapshot, streams bounded internal chunks into the existing destination artifact upload protocol, and verifies the committed destination bytes/SHA-256. Binary payloads do not pass through Host attachments or model text. overwrite defaults to false.",
97-
).with_gpt_action_description("Transfer one Project artifact directly through Control. Requires project:read on source and project:write on destination; both are independently authorized. Streams exact bytes/SHA without Host attachments or model base64. overwrite defaults to false."),
98-
PERMISSION_RISK_ARTIFACT_WRITE,
99-
),
100-
57,
93+
&[PROJECT_READ, PROJECT_WRITE],
94+
),
95+
"Transfer one regular artifact directly from a source Project to a destination Project through Control. Requires source project:read and destination project:write; each Project is independently resolved and authorized. Control fences the exact source bytes/SHA-256/MIME snapshot, streams bounded internal chunks into the existing destination artifact upload protocol, and verifies the committed destination bytes/SHA-256. Binary payloads do not pass through Host attachments or model text. overwrite defaults to false.",
96+
).with_gpt_action_description("Transfer one Project artifact directly through Control. Requires project:read on source and project:write on destination; both are independently authorized. Streams exact bytes/SHA without Host attachments or model base64. overwrite defaults to false."),
97+
PERMISSION_RISK_ARTIFACT_WRITE,
10198
),
10299
adaptive_runtime_direct(
103100
model_spec(

‎crates/webcodex-tool-contracts/src/tool_definition/discovery.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ pub(super) const DEFINITIONS: &[ToolDefinition] = &[
172172
.with_host_orchestration_hint(
173173
super::ToolHostOrchestrationHint::independent_parallel_read(),
174174
),
175-
"Read runtime status; pass exact client_id for one Runner deployment/source alignment, omit for fleet-wide. Reports shared Job concurrency; global mode includes bounded host_context advisory metadata, never authority.",
176-
),
175+
"Read runtime health and protocol/build/source alignment; exact client_id focuses one Runner and its Job concurrency. compact=true or summary_only=true selects sparse counts without inventories. Canonical/API default is full diagnostics with capabilities, build, authority, configuration and connection details; MCP defaults to sparse and accepts compact=false for diagnostics.",
176+
).with_gpt_action_description("Read fleet or exact client_id Runner health and protocol/build/source alignment. compact=true returns sparse counts; omit for full diagnostic inventories and configuration."),
177177
20,
178178
),
179179
model_spec(

0 commit comments

Comments
 (0)