feat: Languageインストラクションの追加

This commit is contained in:
2026-05-13 02:27:30 +09:00
parent 1803b0cf67
commit aa27f62409
8 changed files with 61 additions and 0 deletions
+1
View File
@@ -643,6 +643,7 @@ permission = "write"
let ctx = SystemPromptContext {
now: chrono::Utc::now(),
cwd: &root,
language: manifest::defaults::WORKER_LANGUAGE,
scope: &scope,
tool_names: Vec::new(),
agents_md: None,
+12
View File
@@ -879,10 +879,12 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
};
let resident_exposure_snapshots =
self.resident_exposure_snapshots(&resident, &resident_workflows);
let worker_language = worker_language(&self.manifest.worker);
let scope_snapshot = self.scope.snapshot();
let ctx = SystemPromptContext {
now: chrono::Utc::now(),
cwd: &self.pwd,
language: worker_language,
scope: &scope_snapshot,
tool_names,
agents_md: agents_md_read.body,
@@ -2342,6 +2344,15 @@ fn memory_language(cfg: &manifest::MemoryConfig) -> &str {
.unwrap_or(manifest::defaults::MEMORY_LANGUAGE)
}
fn worker_language(cfg: &manifest::WorkerManifest) -> &str {
let language = cfg.language.trim();
if language.is_empty() {
manifest::defaults::WORKER_LANGUAGE
} else {
language
}
}
/// Outcome of a single extract iteration. Internal to
/// `try_post_run_extract` / `run_extract_once`.
enum ExtractDecision {
@@ -3152,6 +3163,7 @@ mod build_summary_prompt_tests {
fn worker_manifest_generation_settings_become_request_config() {
let manifest = WorkerManifest {
instruction: "unused".into(),
language: manifest::defaults::WORKER_LANGUAGE.into(),
max_tokens: Some(1024),
max_turns: None,
temperature: Some(0.2),
+8
View File
@@ -144,6 +144,8 @@ impl std::fmt::Debug for SystemPromptTemplate {
pub struct SystemPromptContext<'a> {
pub now: DateTime<Utc>,
pub cwd: &'a Path,
/// Language policy exposed to instruction templates as `{{ language }}`.
pub language: &'a str,
pub scope: &'a Scope,
pub tool_names: Vec<String>,
/// Project-level instructions read from the nearest `AGENTS.md`.
@@ -181,6 +183,7 @@ impl<'a> SystemPromptContext<'a> {
Value::from(self.now.to_rfc3339_opts(SecondsFormat::Secs, true)),
);
root.insert("cwd".into(), Value::from(self.cwd.display().to_string()));
root.insert("language".into(), Value::from(self.language));
root.insert(
"tools".into(),
Value::from(
@@ -328,6 +331,7 @@ mod tests {
SystemPromptContext {
now: fixed_now(),
cwd,
language: manifest::defaults::WORKER_LANGUAGE,
scope,
tool_names: tools,
agents_md,
@@ -345,6 +349,7 @@ mod tests {
SystemPromptContext {
now: fixed_now(),
cwd,
language: manifest::defaults::WORKER_LANGUAGE,
scope,
tool_names: Vec::new(),
agents_md: None,
@@ -380,6 +385,9 @@ mod tests {
let rendered = tmpl
.render(&ctx(dir.path(), &scope, vec!["Read".into()], None))
.unwrap();
// Builtin default body must expose the language policy.
assert!(rendered.contains("## Language"));
assert!(rendered.contains("`language`: `match the user's language"));
// Trailing section must be present.
assert!(rendered.contains("## Working boundaries"));
assert!(rendered.contains("Readable:"));