Skip to content

Commit a77efb3

Browse files
committed
feat(rap-protocol): let RAP servers inject system-prompt fragments via their manifest
* `ToolsetManifest` gains an optional `systemPrompt` field (omitted when `None`; servers and runtimes that predate it are unaffected). * When building a session's toolset, the daemon appends each booted server's fragment to the session's `extra_system_prompt` under a "## Instructions from the `<server>` tool server" header, in config order, so every thread of the session sees it. A server that is down contributes neither tools nor a fragment.
1 parent 88bf442 commit a77efb3

6 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎crates/infinity-daemon/src/mcp_proxy.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async fn handle(req: Request<Incoming>, client: McpClient, port: u16) -> Respons
4242
endpoint: format!("http://127.0.0.1:{port}"),
4343
tools: descriptor.tools.into_iter().map(Into::into).collect(),
4444
needs_migration: false,
45+
system_prompt: None,
4546
};
4647
let manifest =
4748
serde_json::to_string(&manifest).expect("bug: failed to serialize RAP manifest");

‎crates/infinity-daemon/src/rap_servers.rs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,20 @@ impl SessionRapManager {
500500
}
501501
}
502502

503-
// Boot each server once to discover its tools.
503+
// Boot each server once to discover its tools and system-prompt fragment.
504504
let http_client = SimpleHttpClient::new();
505505
let mut tools: Vec<Rc<dyn Tool<ChannelSender>>> = Vec::new();
506506
let mut tool_count = 0usize;
507+
let mut server_prompts = String::new();
507508
for server in &servers {
508509
match server.ensure_up().await {
509510
Ok(manifest) => {
511+
if let Some(prompt) = &manifest.system_prompt {
512+
server_prompts.push_str(&format!(
513+
"\n\n## Instructions from the `{}` tool server\n\n{prompt}",
514+
manifest.name
515+
));
516+
}
510517
for def in manifest.tools {
511518
tool_count += 1;
512519
tools.push(Rc::new(ManagedRapTool {
@@ -537,7 +544,7 @@ impl SessionRapManager {
537544
Use the `set_title` tool to give the current thread a short, descriptive title. \
538545
Set it once at the start when the user's intent becomes clear, and update it only \
539546
when the overall scope of work changes significantly. Do not call it repeatedly \
540-
for minor follow-ups within the same task."
547+
for minor follow-ups within the same task.{server_prompts}"
541548
);
542549

543550
let toolset = Rc::new(SessionToolset {

‎crates/rap-github-event-poller/src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn build_manifest(endpoint: &str) -> ToolsetManifest {
2727
description: Some("Subscribe to GitHub repository events via polling (no webhooks required)".to_owned()),
2828
endpoint: endpoint.to_owned(),
2929
needs_migration: false,
30+
system_prompt: None,
3031
tools: vec![ToolDef {
3132
name: "subscribe_github_events".to_owned(),
3233
description:

‎crates/rap-protocol/src/lib.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ pub struct ToolsetManifest {
218218
pub tools: Vec<ToolDef>,
219219
#[serde(default, rename = "needsMigration")]
220220
pub needs_migration: bool,
221+
/// Instructions the runtime appends to the system prompt of every thread
222+
/// that can use this server's tools.
223+
#[serde(
224+
default,
225+
rename = "systemPrompt",
226+
skip_serializing_if = "Option::is_none"
227+
)]
228+
pub system_prompt: Option<String>,
221229
}
222230

223231
#[derive(Debug, Clone, Serialize, Deserialize)]

‎crates/rap-steering-server/src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fn build_manifest(endpoint: &str) -> ToolsetManifest {
3232
description: Some("Discover and load project steering files (CLAUDE.md, AGENTS.md, .kiro/steering/, etc.)".to_owned()),
3333
endpoint: endpoint.to_owned(),
3434
needs_migration: false,
35+
system_prompt: None,
3536
tools: vec![
3637
ToolDef {
3738
name: "list_steering".to_owned(),

‎crates/sandbox-core/src/server.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,7 @@ fn build_manifest(endpoint: &str, needs_migration: bool) -> ToolsetManifest {
21472147
description: Some("Sandboxed code editing and execution tools using jujutsu for filesystem versioning".to_owned()),
21482148
endpoint: endpoint.to_owned(),
21492149
needs_migration,
2150+
system_prompt: None,
21502151
tools: vec![
21512152
ToolDef {
21522153
name: "clone_repo".to_owned(),

0 commit comments

Comments
 (0)