feat: Languageインストラクションの追加
This commit is contained in:
@@ -66,6 +66,8 @@ pub struct WorkerManifestConfig {
|
||||
#[serde(default)]
|
||||
pub instruction: Option<String>,
|
||||
#[serde(default)]
|
||||
pub language: Option<String>,
|
||||
#[serde(default)]
|
||||
pub max_tokens: Option<u32>,
|
||||
#[serde(default)]
|
||||
pub max_turns: Option<NonZeroU32>,
|
||||
@@ -291,6 +293,7 @@ impl WorkerManifestConfig {
|
||||
fn merge(self, upper: Self) -> Self {
|
||||
Self {
|
||||
instruction: upper.instruction.or(self.instruction),
|
||||
language: upper.language.or(self.language),
|
||||
max_tokens: upper.max_tokens.or(self.max_tokens),
|
||||
max_turns: upper.max_turns.or(self.max_turns),
|
||||
temperature: upper.temperature.or(self.temperature),
|
||||
@@ -429,6 +432,10 @@ impl TryFrom<PodManifestConfig> for PodManifest {
|
||||
.worker
|
||||
.instruction
|
||||
.unwrap_or_else(|| defaults::DEFAULT_INSTRUCTION.to_string()),
|
||||
language: cfg
|
||||
.worker
|
||||
.language
|
||||
.unwrap_or_else(|| defaults::WORKER_LANGUAGE.to_string()),
|
||||
max_tokens: cfg.worker.max_tokens,
|
||||
max_turns: cfg.worker.max_turns,
|
||||
temperature: cfg.worker.temperature,
|
||||
|
||||
@@ -33,6 +33,11 @@ pub const COMPACT_RETAINED_TOKENS: u64 = 8000;
|
||||
/// `$insomnia/` / `$user/` / `$workspace/` namespaces.
|
||||
pub const DEFAULT_INSTRUCTION: &str = "$insomnia/default";
|
||||
|
||||
/// Default language policy used by the main worker for normal prose
|
||||
/// responses. See [`crate::WorkerManifest::language`].
|
||||
pub const WORKER_LANGUAGE: &str =
|
||||
"match the user's language unless they explicitly request another language";
|
||||
|
||||
/// Token budget for auto-read file contents injected into the new
|
||||
/// session after compaction. Limits how much raw file text the
|
||||
/// compact worker can pull into the compacted context via
|
||||
|
||||
@@ -173,6 +173,12 @@ pub struct WorkerManifest {
|
||||
/// unset manifests fall through to [`defaults::DEFAULT_INSTRUCTION`].
|
||||
#[serde(default = "default_instruction")]
|
||||
pub instruction: String,
|
||||
/// Language policy used by the main worker for normal prose responses.
|
||||
/// Free-form so workspaces can use names like `English`, `Japanese`,
|
||||
/// locale tags, or a policy phrase. Unset manifests fall through to
|
||||
/// [`defaults::WORKER_LANGUAGE`].
|
||||
#[serde(default = "default_worker_language")]
|
||||
pub language: String,
|
||||
#[serde(default)]
|
||||
pub max_tokens: Option<u32>,
|
||||
#[serde(default)]
|
||||
@@ -241,6 +247,10 @@ fn default_instruction() -> String {
|
||||
defaults::DEFAULT_INSTRUCTION.to_string()
|
||||
}
|
||||
|
||||
fn default_worker_language() -> String {
|
||||
defaults::WORKER_LANGUAGE.to_string()
|
||||
}
|
||||
|
||||
impl Default for ToolOutputLimits {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@@ -689,6 +699,16 @@ model_id = "claude-sonnet-4-20250514"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn worker_language_defaults_and_parses() {
|
||||
let manifest = PodManifest::from_toml(MINIMAL_REQUIRED).unwrap();
|
||||
assert_eq!(manifest.worker.language, defaults::WORKER_LANGUAGE);
|
||||
|
||||
let toml = MINIMAL_REQUIRED.replace("[worker]\n", "[worker]\nlanguage = \"Japanese\"\n");
|
||||
let manifest = PodManifest::from_toml(&toml).unwrap();
|
||||
assert_eq!(manifest.worker.language, "Japanese");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_worker_output_limits() {
|
||||
let toml = MINIMAL_REQUIRED.replace(
|
||||
|
||||
Reference in New Issue
Block a user