requirements.authoring.openai_defaults
Requirements index · View definition
Requirement
An OpenAI configuration MAY omit
model; the effective model MUST then begpt-6.1-sol. Whenoptions.reasoning.effortis omitted, the request MUST useloweffort, preserving other reasoning options. Whenoptions.max_output_tokensis omitted, the request MUST use an output-token limit of 16,384. These option defaults MUST apply even when the model is overridden. An explicit model, reasoning effort, or output-token limit MUST override its corresponding default. Defaults MUST NOT be written into omitted configuration fields on serialization. An explicitly empty model MUST still be rejected.
Rationale
No gaps found in requirements.authoring.openai_defaults; every obligation has code and a test, and there are no {fixme} references.
- Default model
gpt-6.1-sol:src/config.rs#impl[OpenAiConfig]/fn[model]falls back to it whenmodelisNone, andimpl[BackendConfig]/fn[model_ref]uses it.tests/configuration.rs#fn[openai_defaults_are_effective_only_and_explicit_values_win]checks the effective model.tests/authoring_cli.rs#fn[openai_key_only_profile_defaults_to_sol_and_accepts_overrides]checks the model in the request body. - Default effort
low, preserving other reasoning options:src/config.rs#impl[BackendConfig]/fn[options_json]addseffort: "low"to the reasoning object only if it is absent. Both tests check this, and the configuration test coversreasoning.summarybeing preserved. - Default
max_output_tokensof 16,384:options_jsoninserts it only if the key is absent. Both tests check it, andRigProvider::connectpasses the result into the request. - Option defaults still apply with an overridden model:
options_jsondoes not depend on the model. The configuration test coversgpt-6-lunaandadaptive, and the CLI test coversgpt-6-luna. - Explicit values override defaults: defaults are written only when the key is absent. The configuration test covers explicit model and effort, and the CLI test covers explicit effort
mediumandmax_output_tokens8192.fn[adaptive_routes_fresh_assessments_and_records_each_model]also checks explicit effort and token limit in requests. - Defaults not serialized:
OpenAiConfigusesskip_serializing_ifformodeland for the options map, and defaults are applied only inmodel()andoptions_json(). The configuration test asserts that the serialized TOML has nomax_output_tokensand thatmodel =andeffort =appear only when set. It also asserts that the serialized TOML round-trips. - Empty model rejected:
model = ''parses toSome(""), somodel()returns an empty string, andsrc/config.rs#impl[BackendConfig]/fn[validate]rejects it. The configuration test asserts that parsingmodel = ''fails.
The carrying-out code (model, options_json, validate, plus model_ref, which validate calls) is reachable from items marked {impl}. I saw no unspecified observable behavior in the marked code.
Inputs
Implementation
Input 2: outline src/config.rs impl[BackendConfig]/fn[options_json]
- File:
src/config.rs - Selector:
impl[BackendConfig]/fn[options_json] - Kind:
fn src/config.rs:531–555
// {impl}`requirements.authoring.configuration_storage`
// {impl}`requirements.authoring.openai_defaults`
pub fn options_json(&self) -> io::Result<serde_json::Value> {
for value in self.options().values() {
value.validate()?;
}
let mut options = serde_json::to_value(self.options()).map_err(io::Error::other)?;
if let Self::Openai(_) = self {
let options = options
.as_object_mut()
.expect("configuration options are a map");
options
.entry("max_output_tokens")
.or_insert_with(|| serde_json::json!(16_384));
let reasoning = options
.entry("reasoning")
.or_insert_with(|| serde_json::json!({}));
if let Some(reasoning) = reasoning.as_object_mut() {
reasoning
.entry("effort")
.or_insert_with(|| serde_json::json!("low"));
}
}
Ok(options)
}
Input 3: outline src/config.rs impl[BackendConfig]/fn[validate]
- File:
src/config.rs - Selector:
impl[BackendConfig]/fn[validate] - Kind:
fn src/config.rs:557–675
// {impl}`requirements.configuration.loading`
// {impl}`requirements.configuration.feature_sections`
// {impl}`requirements.authoring.openai_defaults`
// {impl}`requirements.authoring.configuration_structure`
fn validate(&self, path: &Path, setting: &str) -> io::Result<()> {
if self.model_ref().model.is_empty() {
return Err(invalid(
path,
&format!("{setting}.model"),
"expected a nonempty model ID",
));
}
let api_key_env = match self {
Self::Ollama(config) => &config.api_key_env,
Self::Openai(config) => &config.api_key_env,
Self::Bedrock(_) => &None,
};
if let Some(name) = api_key_env
&& (name.is_empty() || name.contains(['=', '\0']))
{
return Err(invalid(
path,
&format!("{setting}.api_key_env"),
"expected a nonempty environment variable name without '=' or NUL",
));
}
match self {
Self::Bedrock(config) => {
if let Some(credentials) = &config.credentials {
if config.aws_profile.is_some() {
return Err(invalid(
path,
&format!("{setting}.credentials"),
"credentials and aws_profile cannot both be set",
));
}
for (field, value) in [
("access_key_id", Some(&credentials.access_key_id)),
("secret_access_key", Some(&credentials.secret_access_key)),
("session_token", credentials.session_token.as_ref()),
] {
if value.is_some_and(|value| value.expose_secret().is_empty()) {
return Err(invalid(
path,
&format!("{setting}.credentials.{field}"),
"credential values must be nonempty",
));
}
}
}
}
Self::Ollama(config) => {
if let Some(key) = &config.api_key {
if config.api_key_env.is_some() {
return Err(invalid(
path,
&format!("{setting}.api_key"),
"api_key and api_key_env cannot both be set",
));
}
if key.expose_secret().is_empty() {
return Err(invalid(
path,
&format!("{setting}.api_key"),
"credential values must be nonempty",
));
}
}
}
Self::Openai(config) => {
if let Some(key) = &config.api_key {
if config.api_key_env.is_some() {
return Err(invalid(
path,
&format!("{setting}.api_key"),
"api_key and api_key_env cannot both be set",
));
}
if key.expose_secret().is_empty() {
return Err(invalid(
path,
&format!("{setting}.api_key"),
"credential values must be nonempty",
));
}
}
}
}
for (key, value) in self.options() {
let field = format!("{setting}.options.{key}");
if matches!(
key.as_str(),
"model"
| "modelId"
| "model_id"
| "input"
| "instructions"
| "previous_response_id"
| "conversation"
| "prompt"
| "messages"
| "system"
| "tools"
| "tool_choice"
| "toolChoice"
| "toolConfig"
) {
return Err(invalid(
path,
&field,
"options cannot replace the model, prompt, or tools",
));
}
value
.validate()
.map_err(|error| invalid(path, &field, error))?;
}
Ok(())
}
Input 4: outline src/config.rs impl[OpenAiConfig]/fn[model]
- File:
src/config.rs - Selector:
impl[OpenAiConfig]/fn[model] - Kind:
fn src/config.rs:724–727
// {impl}`requirements.authoring.openai_defaults`
pub fn model(&self) -> &str {
self.model.as_deref().unwrap_or("gpt-6.1-sol")
}
Tests
Input 5: outline tests/authoring_cli.rs fn[openai_key_only_profile_defaults_to_sol_and_accepts_overrides]
- File:
tests/authoring_cli.rs - Selector:
fn[openai_key_only_profile_defaults_to_sol_and_accepts_overrides] - Kind:
fn tests/authoring_cli.rs:5286–5332
// {test}`requirements.authoring.openai_defaults`
// {test}`requirements.authoring.credentials`
// {test}`requirements.authoring.adaptive`
#[test]
fn openai_key_only_profile_defaults_to_sol_and_accepts_overrides() {
mock_server_waits_for_remaining_request_headers();
for (extra, model, effort, max_tokens) in [
("", "gpt-6.1-sol", "low", 16_384),
("model = 'gpt-6-luna'\n", "gpt-6-luna", "low", 16_384),
(
"model = 'gpt-6-luna'\n[authoring.configs.api.options]\nmax_output_tokens = 8192\n[authoring.configs.api.options.reasoning]\neffort = 'medium'\n",
"gpt-6-luna",
"medium",
8192,
),
] {
let submit = json!({"determination":false,"rationale":"Fixture assessment."});
let server = Server::start(vec![json!({
"id":"resp_submit", "object":"response", "status":"completed",
"model":model, "output":[{
"type":"function_call", "id":"fc_submit", "call_id":"submit",
"name":"submit_judgment", "arguments":submit.to_string(), "status":"completed"
}],
"usage":{"input_tokens":1,"output_tokens":1,"total_tokens":2}
})]);
let fixture = Fixture::new(&server.endpoint);
// Only the endpoint is fixture-specific; policy/concurrency/model are optional.
fs::write(fixture.config.join("habeas/config.toml"), format!(
"version = 1\n[authoring]\ndefault = 'api'\n[authoring.configs.api]\nbackend = 'openai'\napi_key = '{AUTH}'\nendpoint = '{}'\n{extra}", server.endpoint)).unwrap();
let output = fixture.run(&["author", SUBJECT]);
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
let requests = server.finish();
assert_eq!(requests.len(), 1);
assert_eq!(requests[0].body["model"], model);
assert_eq!(requests[0].body["reasoning"]["effort"], effort);
assert_eq!(requests[0].body["max_output_tokens"], max_tokens);
assert!(requests[0].headers.contains(&format!("Bearer {AUTH}")));
let usage = fixture.usage();
assert_eq!(usage["model"], model);
assert_eq!(usage["policy"], "once");
assert!(!usage.to_string().contains(AUTH));
}
}
Input 6: outline tests/authoring_cli.rs fn[adaptive_routes_fresh_assessments_and_records_each_model]
- File:
tests/authoring_cli.rs - Selector:
fn[adaptive_routes_fresh_assessments_and_records_each_model] - Kind:
fn tests/authoring_cli.rs:5361–5517
// {test}`requirements.authoring.adaptive`
// {test}`requirements.authoring.openai_defaults`
// {test}`requirements.authoring.policy`
#[test]
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.authoring.confirmation`
fn adaptive_routes_fresh_assessments_and_records_each_model() {
let response = |arguments: Value| {
json!({
"id":"resp_submit", "object":"response", "status":"completed",
"model":"mock", "output":[{
"type":"function_call", "id":"fc_submit", "call_id":"submit",
"name":"submit_judgment", "arguments":arguments.to_string(), "status":"completed"
}], "usage":{"input_tokens":1,"output_tokens":1,"total_tokens":2}
})
};
for (existing_fixme, first, policy, expected_models, reason) in [
(
false,
json!({"determination":true,"rationale":"Good."}),
"",
vec!["gpt-5.4-mini"],
None,
),
(
false,
json!({"determination":false,"rationale":"MINI_ONLY_RATIONALE_SENTINEL"}),
"",
vec!["gpt-5.4-mini", "gpt-6.1-sol"],
Some("mini_false"),
),
(
false,
json!({"determination":{"FIXME":["Gap"]},"rationale":"MINI_ONLY_RATIONALE_SENTINEL"}),
"",
vec!["gpt-5.4-mini", "gpt-6.1-sol"],
Some("mini_fixme"),
),
(
false,
json!({"bad":"submission"}),
"",
vec!["gpt-5.4-mini", "gpt-6.1-sol"],
Some("mini_assessment_failed"),
),
(
true,
json!({"determination":true,"rationale":"Good."}),
"",
vec!["gpt-6.1-sol"],
Some("existing_fixme"),
),
(
false,
json!({"determination":true,"rationale":"FIRST_AGREEMENT_RATIONALE"}),
"policy = 'confirm'\n",
vec!["gpt-5.4-mini", "gpt-5.4-mini"],
None,
),
] {
let mut replies = vec![response(first)];
if expected_models.len() == 2 {
replies.push(response(json!({"determination":true,"rationale":"Good."})));
}
let server = Server::start(replies);
let fixture = Fixture::new(&server.endpoint);
if !existing_fixme {
fs::write(fixture.project.join("src/lib.rs"), "// {impl}`requirements.ready`\npub fn ready() {}\n// {test}`requirements.ready`\nfn ready_test() {}\n// A plain FIXME is not an acknowledgment.\n").unwrap();
}
fs::write(fixture.config.join("habeas/config.toml"), format!(
"version = 1\n[authoring]\ndefault = 'api'\n[authoring.configs.api]\nbackend = 'openai'\nmodel = 'adaptive'\n{policy}endpoint = '{}'\napi_key_env = 'HABEAS_TEST_MODEL_KEY'\n[authoring.configs.api.options]\nmax_output_tokens = 8192\nreasoning = {{ effort = 'medium' }}\n", server.endpoint)).unwrap();
let output = fixture.run(&["author", SUBJECT]);
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
let requests = server.finish();
assert_eq!(
requests
.iter()
.map(|r| r.body["model"].as_str().unwrap())
.collect::<Vec<_>>(),
expected_models
);
for request in &requests {
assert!(
request
.headers
.to_lowercase()
.contains(&format!("authorization: bearer {}", AUTH.to_lowercase()))
);
assert!(
!request
.body
.to_string()
.contains("MINI_ONLY_RATIONALE_SENTINEL")
);
assert_eq!(
request.body["input"].as_array().unwrap().len(),
1,
"fresh conversation"
);
assert_eq!(request.body["reasoning"]["effort"], "medium");
assert_eq!(request.body["max_output_tokens"], 8192);
}
let evidence: Value =
serde_json::from_slice(&fs::read(&fixture.evidence).unwrap()).unwrap();
assert_eq!(evidence["determination"], true);
if !policy.is_empty() {
assert_eq!(evidence["rationale"], "FIRST_AGREEMENT_RATIONALE");
}
let logs: Vec<Value> = fs::read_dir(fixture.state.join("habeas/authoring/usage"))
.unwrap()
.map(|entry| serde_json::from_slice(&fs::read(entry.unwrap().path()).unwrap()).unwrap())
.collect();
let expected_policy = if policy.is_empty() { "once" } else { "confirm" };
assert!(
logs.iter().all(|log| log["policy"] == expected_policy),
"{logs:?}"
);
let parent = logs
.iter()
.find(|log| log["subject"] == SUBJECT && log["model"] == "adaptive")
.unwrap();
assert_eq!(parent["routing_reason"].as_str(), reason);
assert!(!parent["attempts"].as_array().unwrap().is_empty());
let actual: Vec<_> = logs
.iter()
.filter(|log| log["model"] != "adaptive")
.collect();
assert_eq!(actual.len(), expected_models.len());
let ids: std::collections::BTreeSet<_> = actual
.iter()
.map(|log| log["run_id"].as_str().unwrap())
.collect();
assert_eq!(ids.len(), actual.len());
let links: Vec<_> = logs
.iter()
.flat_map(|log| log["attempts"].as_array().into_iter().flatten())
.filter_map(Value::as_str)
.collect();
for id in ids {
assert!(
links
.iter()
.any(|path| path.ends_with(&format!("{id}.json")))
);
}
for model in expected_models {
assert!(
logs.iter()
.any(|log| log["model"] == model && log["request_count"] == 1)
);
}
}
}
Input 7: outline tests/configuration.rs fn[openai_policy_defaults_to_once_without_changing_explicit_policy]
- File:
tests/configuration.rs - Selector:
fn[openai_policy_defaults_to_once_without_changing_explicit_policy] - Kind:
fn tests/configuration.rs:1801–1834
// {test}`requirements.authoring.policy`
// {test}`requirements.authoring.openai_defaults`
// {test}`requirements.authoring.configuration_structure`
#[test]
fn openai_policy_defaults_to_once_without_changing_explicit_policy() {
use habeas::config::AssessmentPolicy;
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("config.toml");
for (extra, expected) in [
("", AssessmentPolicy::Once),
("policy = 'confirm'\n", AssessmentPolicy::Confirm),
] {
let config = UserConfig::parse(
&format!("version = 1\n[authoring.configs.api]\nbackend = 'openai'\n{extra}"),
&path,
)
.unwrap();
let resolved =
resolve_authoring_from(&path, Some(&config), dir.path(), Some("api")).unwrap();
assert_eq!(resolved.effective_policy(None), expected);
assert_eq!(
resolved.effective_policy(Some(AssessmentPolicy::Confirm)),
AssessmentPolicy::Confirm
);
assert_eq!(
resolved.effective_policy(Some(AssessmentPolicy::Once)),
AssessmentPolicy::Once
);
assert_eq!(
config.to_toml().unwrap().contains("policy ="),
!extra.is_empty()
);
}
}
Input 8: outline tests/configuration.rs fn[openai_defaults_are_effective_only_and_explicit_values_win]
- File:
tests/configuration.rs - Selector:
fn[openai_defaults_are_effective_only_and_explicit_values_win] - Kind:
fn tests/configuration.rs:1836–1887
// {test}`requirements.authoring.openai_defaults`
// {test}`requirements.authoring.configuration_structure`
// {test}`requirements.authoring.configuration_serialization`
// {test}`requirements.configuration.serialization`
#[test]
fn openai_defaults_are_effective_only_and_explicit_values_win() {
let path = Path::new("settings.toml");
let base =
"version = 1\n[authoring.configs.api]\nbackend = 'openai'\napi_key = 'fixture-key'\n";
for (extra, model, effort) in [
("", "gpt-6.1-sol", Some("low")),
(
"[authoring.configs.api.options.reasoning]\nsummary = 'auto'\n",
"gpt-6.1-sol",
Some("low"),
),
(
"[authoring.configs.api.options.reasoning]\neffort = 'medium'\n",
"gpt-6.1-sol",
Some("medium"),
),
("model = 'gpt-6-luna'\n", "gpt-6-luna", Some("low")),
("model = 'adaptive'\n", "adaptive", Some("low")),
(
"model = 'gpt-6-luna'\n[authoring.configs.api.options.reasoning]\neffort = 'high'\n",
"gpt-6-luna",
Some("high"),
),
] {
let config = UserConfig::parse(&format!("{base}{extra}"), path).unwrap();
let backend = &config.authoring.as_ref().unwrap().configs["api"].backend;
assert_eq!(backend.model_ref().model, model);
let options = backend.options_json().unwrap();
assert_eq!(options["reasoning"]["effort"].as_str(), effort);
assert_eq!(options["max_output_tokens"], 16_384);
if extra.contains("summary") {
assert_eq!(options["reasoning"]["summary"], "auto");
}
let serialized = config.to_toml().unwrap();
assert!(!serialized.contains("max_output_tokens"));
assert_eq!(serialized.contains("model ="), extra.contains("model ="));
assert_eq!(serialized.contains("effort ="), extra.contains("effort ="));
if extra.contains("options.reasoning") {
assert!(
serialized.contains("[authoring.configs.api.options.reasoning]"),
"{serialized}"
);
}
assert_eq!(UserConfig::parse(&serialized, path).unwrap(), config);
}
assert!(UserConfig::parse(&format!("{base}model = ''\n"), path).is_err());
}
Other sources
Input 1: requirements selection requirements.authoring.openai_defaults
requirements.authoring.openai_defaults:md/requirements/authoring.md:1693–1703
:::{req} openai_defaults
{impl}`requirements.configuration.feature_sections`
An OpenAI configuration MAY omit `model`; the effective model MUST then be
`gpt-6.1-sol`. When `options.reasoning.effort` is omitted, the request MUST use
`low` effort, preserving other reasoning options. When `options.max_output_tokens`
is omitted, the request MUST use an output-token limit of 16,384. These option
defaults MUST apply even when the model is overridden. An explicit model,
reasoning effort, or output-token limit MUST override its corresponding default.
Defaults MUST NOT be written into omitted configuration fields on serialization.
An explicitly empty model MUST still be rejected.
:::
Input 9: outline src/config.rs impl[BackendConfig]/fn[model_ref]
- File:
src/config.rs - Selector:
impl[BackendConfig]/fn[model_ref] - Kind:
fn src/config.rs:506–521
pub fn model_ref(&self) -> ModelRef {
match self {
Self::Bedrock(config) => ModelRef {
backend: BackendKind::Bedrock,
model: config.model.clone(),
},
Self::Openai(config) => ModelRef {
backend: BackendKind::Openai,
model: config.model().to_owned(),
},
Self::Ollama(config) => ModelRef {
backend: BackendKind::Ollama,
model: config.model.clone(),
},
}
}