feat: inject background-jobs prompt guidance when jobs are enabled
Agents whose function pool includes job__* declarations get a Background Jobs section teaching start/check/collect/cancel discipline and the snapshot/no-persistence semantics. Presence of the declarations doubles as the jobs_enabled predicate, so a context with function calling off or max_concurrent_jobs 0 sees no job prompt text.
This commit is contained in:
+18
-3
@@ -3,15 +3,19 @@ use super::*;
|
|||||||
use crate::{
|
use crate::{
|
||||||
client::Model,
|
client::Model,
|
||||||
config::memory,
|
config::memory,
|
||||||
function::{Functions, jobs::DEFAULT_MAX_CONCURRENT_JOBS, run_llm_function},
|
function::{
|
||||||
|
Functions,
|
||||||
|
jobs::{DEFAULT_MAX_CONCURRENT_JOBS, JOB_FUNCTION_PREFIX},
|
||||||
|
run_llm_function,
|
||||||
|
},
|
||||||
graph, rag,
|
graph, rag,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::rag_cache::RagKey;
|
use super::rag_cache::RagKey;
|
||||||
use crate::config::paths;
|
use crate::config::paths;
|
||||||
use crate::config::prompts::{
|
use crate::config::prompts::{
|
||||||
DEFAULT_SPAWN_INSTRUCTIONS, DEFAULT_TEAMMATE_INSTRUCTIONS, DEFAULT_TODO_INSTRUCTIONS,
|
DEFAULT_JOB_INSTRUCTIONS, DEFAULT_SPAWN_INSTRUCTIONS, DEFAULT_TEAMMATE_INSTRUCTIONS,
|
||||||
DEFAULT_USER_INTERACTION_INSTRUCTIONS,
|
DEFAULT_TODO_INSTRUCTIONS, DEFAULT_USER_INTERACTION_INSTRUCTIONS,
|
||||||
};
|
};
|
||||||
use crate::graph::types::RagNode;
|
use crate::graph::types::RagNode;
|
||||||
use crate::graph::{Graph, GraphParser, NodeType};
|
use crate::graph::{Graph, GraphParser, NodeType};
|
||||||
@@ -450,6 +454,17 @@ impl Agent {
|
|||||||
output.push_str(DEFAULT_SPAWN_INSTRUCTIONS);
|
output.push_str(DEFAULT_SPAWN_INSTRUCTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Job declarations are appended at init iff jobs are enabled for this
|
||||||
|
// agent, so their presence doubles as the jobs_enabled predicate.
|
||||||
|
if self
|
||||||
|
.functions
|
||||||
|
.declarations()
|
||||||
|
.iter()
|
||||||
|
.any(|f| f.name.starts_with(JOB_FUNCTION_PREFIX))
|
||||||
|
{
|
||||||
|
output.push_str(DEFAULT_JOB_INSTRUCTIONS);
|
||||||
|
}
|
||||||
|
|
||||||
output.push_str(DEFAULT_TEAMMATE_INSTRUCTIONS);
|
output.push_str(DEFAULT_TEAMMATE_INSTRUCTIONS);
|
||||||
output.push_str(DEFAULT_USER_INTERACTION_INSTRUCTIONS);
|
output.push_str(DEFAULT_USER_INTERACTION_INSTRUCTIONS);
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,16 @@ pub(in crate::config) const DEFAULT_SPAWN_INSTRUCTIONS: &str = indoc! {"
|
|||||||
4. **Respond promptly**; the child agent is blocked and waiting (5-minute timeout).
|
4. **Respond promptly**; the child agent is blocked and waiting (5-minute timeout).
|
||||||
"};
|
"};
|
||||||
|
|
||||||
|
pub(in crate::config) const DEFAULT_JOB_INSTRUCTIONS: &str = indoc! {"
|
||||||
|
## Background Jobs
|
||||||
|
|
||||||
|
For long-running tool calls (builds, test suites, slow commands), call `job__start` and keep
|
||||||
|
working instead of blocking. Check progress with `job__check` (sparingly), block on the result
|
||||||
|
with `job__collect`, cancel with `job__cancel`, and list jobs with `job__list`. Collect or
|
||||||
|
cancel every job you started before ending your turn. Jobs run against a snapshot of the
|
||||||
|
current config/environment and do not survive coyote exiting."
|
||||||
|
};
|
||||||
|
|
||||||
pub(in crate::config) const DEFAULT_TEAMMATE_INSTRUCTIONS: &str = indoc! {"
|
pub(in crate::config) const DEFAULT_TEAMMATE_INSTRUCTIONS: &str = indoc! {"
|
||||||
## Teammate Messaging
|
## Teammate Messaging
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user