Regenerate the bundled mio-code identity prompt
This commit is contained in:
@@ -37,7 +37,7 @@ def main():
|
||||
]
|
||||
for const_name, filename in TEMPLATES.items():
|
||||
path = TEMPLATE_DIR / filename
|
||||
data = path.read_bytes()
|
||||
data = path.read_bytes().replace(b"\r\n", b"\n")
|
||||
enc = xor_encrypt(data, SEEDS[const_name])
|
||||
arr = ", ".join(str(b) for b in enc)
|
||||
# `#[rustfmt::skip]` keeps the multi-KB byte array on a single line so
|
||||
|
||||
@@ -139,7 +139,7 @@ pub struct PromptContext {
|
||||
#[serde(default = "default_system_prompt_label")]
|
||||
pub system_prompt_label: String,
|
||||
}
|
||||
/// Default identity on trim-tool-descriptions (`You are Mio released by hoshizukimio`).
|
||||
/// Default name for the coding assistant in the base system prompt.
|
||||
pub const DEFAULT_SYSTEM_PROMPT_LABEL: &str = "Mio";
|
||||
fn default_system_prompt_label() -> String {
|
||||
DEFAULT_SYSTEM_PROMPT_LABEL.to_string()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -70,15 +70,17 @@ mod tests {
|
||||
/// If this fails, run: `python3 scripts/encrypt_templates.py`
|
||||
#[test]
|
||||
fn test_encrypted_templates_not_stale() {
|
||||
fn xor_encrypt(data: &[u8], seed: u8) -> Vec<u8> {
|
||||
data.iter()
|
||||
fn xor_encrypt(template: &str, seed: u8) -> Vec<u8> {
|
||||
template
|
||||
.replace("\r\n", "\n")
|
||||
.bytes()
|
||||
.enumerate()
|
||||
.map(|(i, &b)| b ^ seed.wrapping_add(i as u8))
|
||||
.map(|(i, b)| b ^ seed.wrapping_add(i as u8))
|
||||
.collect()
|
||||
}
|
||||
let base_raw = include_bytes!("../../templates/prompt.md");
|
||||
let apply_patch_raw = include_bytes!("../../templates/apply_patch_prompt.md");
|
||||
let subagent_raw = include_bytes!("../../templates/subagent_prompt.md");
|
||||
let base_raw = include_str!("../../templates/prompt.md");
|
||||
let apply_patch_raw = include_str!("../../templates/apply_patch_prompt.md");
|
||||
let subagent_raw = include_str!("../../templates/subagent_prompt.md");
|
||||
|
||||
assert_eq!(
|
||||
BASE_PROMPT_ENC,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
You are ${{ system_prompt_label }} released by hoshizukimio. You are ${%- if is_non_interactive %} an autonomous agent that completes software engineering tasks. There is no human operator in this session.${%- else %} an interactive CLI tool that helps users with software engineering tasks.${%- endif %} Your main goal is to complete the user's request, denoted within the <user_query> tag.
|
||||
You are ${{ system_prompt_label }}, the coding assistant in mio-code, maintained by hoshizukimio. When asked about your identity, distinguish the mio-code application and its maintainer from the underlying model and its provider. You are ${%- if is_non_interactive %} an autonomous agent that completes software engineering tasks. There is no human operator in this session.${%- else %} an interactive CLI tool that helps users with software engineering tasks.${%- endif %} Your main goal is to complete the user's request, denoted within the <user_query> tag.
|
||||
|
||||
<dangerous_actions>
|
||||
- Consider an action's reversibility and who it affects. Proceed with requested, reversible local work. Before destructive or hard-to-reverse actions, or changes to shared systems, confirm with the user unless they have explicitly authorized that action.
|
||||
|
||||
@@ -15,6 +15,7 @@ import threading
|
||||
TEXT = "mio smoke passed"
|
||||
MODEL = "mio-smoke-model"
|
||||
KEY = "mio-test-credential"
|
||||
IDENTITY = b"You are Mio, the coding assistant in mio-code, maintained by hoshizukimio."
|
||||
ROUTES = {
|
||||
"chat_completions": "/v1/chat/completions",
|
||||
"responses": "/v1/responses",
|
||||
@@ -294,6 +295,7 @@ def verify(binary, tui):
|
||||
assert requests.empty(), "listing models contacted the model endpoint"
|
||||
assert TEXT in run("-p", "Respond with the test phrase.")
|
||||
saw_inference = False
|
||||
saw_identity = False
|
||||
while not requests.empty():
|
||||
method, path, headers, body = requests.get_nowait()
|
||||
headers = {key.lower(): value for key, value in headers.items()}
|
||||
@@ -310,7 +312,9 @@ def verify(binary, tui):
|
||||
assert not headers.get("authorization") and not headers.get("x-api-key"), headers
|
||||
actual_model = json.loads(body)["model"]
|
||||
assert actual_model == MODEL, (backend, method, path, actual_model)
|
||||
saw_identity |= IDENTITY in body
|
||||
assert saw_inference, backend
|
||||
assert saw_identity, (backend, "model request lacked the mio-code identity")
|
||||
assert unexpected.empty(), unexpected.get_nowait()
|
||||
print(f"Passed {backend} {'with credentials' if keyed else 'without credentials'}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user