Skip to content

Commit 67b1434

Browse files
committed
Sync bundled Codex model constants
1 parent d06b13b commit 67b1434

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ If no new rule is detected -> do not update the file.
9090
- Do not keep or add public sample projects; repository focus is SDK + tests only.
9191
- Upstream sync automation must track real `openai/codex` CLI changes (flags/models/features), not TypeScript SDK surface diffs, and open actionable repository issues for required SDK follow-up.
9292
- Automatically opened upstream sync issues must include change summary/checklist and assign Copilot by default.
93+
- For `openai/codex` repo sync/update work, always inspect `submodules/openai-codex/codex-rs/core/models.json` and reconcile SDK model constants against that bundled catalog because it is the repo-authoritative model source.
94+
- At the end of implementation/code-change tasks, create a git commit unless the user explicitly says not to, so the workspace ends in a reviewable state.
9395
- Run verification in this order:
9496
- focused tests for changed behavior
9597
- full solution tests
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System.Reflection;
2+
using System.Text.Json;
3+
using ManagedCode.CodexSharpSDK.Models;
4+
5+
namespace ManagedCode.CodexSharpSDK.Tests.Unit;
6+
7+
public class CodexModelsTests
8+
{
9+
private const string SolutionFileName = "ManagedCode.CodexSharpSDK.slnx";
10+
private const string BundledModelsFileName = "models.json";
11+
12+
[Test]
13+
public async Task CodexModels_ContainAllBundledUpstreamModelSlugs()
14+
{
15+
var bundledModelSlugs = await ReadBundledModelSlugsAsync();
16+
var sdkModelSlugs = GetSdkModelSlugs();
17+
var missingBundledSlugs = bundledModelSlugs
18+
.Except(sdkModelSlugs, StringComparer.Ordinal)
19+
.ToArray();
20+
21+
await Assert.That(missingBundledSlugs).IsEmpty();
22+
}
23+
24+
private static string[] GetSdkModelSlugs()
25+
{
26+
return typeof(CodexModels)
27+
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly)
28+
.Where(field => field is { IsLiteral: true, IsInitOnly: false, FieldType: not null } && field.FieldType == typeof(string))
29+
.Select(field => (string)field.GetRawConstantValue()!)
30+
.ToArray();
31+
}
32+
33+
private static async Task<string[]> ReadBundledModelSlugsAsync()
34+
{
35+
var modelsPath = ResolveBundledModelsFilePath();
36+
using var stream = File.OpenRead(modelsPath);
37+
using var document = await JsonDocument.ParseAsync(stream);
38+
39+
return document.RootElement
40+
.GetProperty("models")
41+
.EnumerateArray()
42+
.Select(model => model.GetProperty("slug").GetString())
43+
.OfType<string>()
44+
.ToArray();
45+
}
46+
47+
private static string ResolveBundledModelsFilePath()
48+
{
49+
return Path.Combine(
50+
ResolveRepositoryRootPath(),
51+
"submodules",
52+
"openai-codex",
53+
"codex-rs",
54+
"core",
55+
BundledModelsFileName);
56+
}
57+
58+
private static string ResolveRepositoryRootPath()
59+
{
60+
var current = new DirectoryInfo(AppContext.BaseDirectory);
61+
while (current is not null)
62+
{
63+
if (File.Exists(Path.Combine(current.FullName, SolutionFileName)))
64+
{
65+
return current.FullName;
66+
}
67+
68+
current = current.Parent;
69+
}
70+
71+
throw new InvalidOperationException("Could not locate repository root from test execution directory.");
72+
}
73+
}

CodexSharpSDK/Models/CodexModels.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public static class CodexModels
1212
public const string Gpt51 = "gpt-5.1";
1313
public const string Gpt5Codex = "gpt-5-codex";
1414
public const string Gpt5 = "gpt-5";
15+
public const string GptOss120b = "gpt-oss-120b";
16+
public const string GptOss20b = "gpt-oss-20b";
1517
public const string Gpt51CodexMini = "gpt-5.1-codex-mini";
1618
public const string Gpt5CodexMini = "gpt-5-codex-mini";
1719
}

docs/Features/release-and-sync-automation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Keep package quality and upstream Codex CLI parity automatically verified throug
4545
- Codex CLI watch runs daily and opens issue when upstream `openai/codex` changed since pinned submodule SHA.
4646
- Completing a Codex CLI sync issue must update the pinned `submodules/openai-codex` commit after validation.
4747
- Sync issue body must derive flag changes from CLI source snapshots, model changes from `codex-rs/core/models.json`, and feature changes from `codex-rs/core/config.schema.json` so alerts stay actionable.
48+
- SDK model constants must cover every bundled slug from `submodules/openai-codex/codex-rs/core/models.json` whenever upstream Codex repo sync work updates the pinned submodule.
4849
- Sync issue must assign Copilot by default.
4950
- Duplicate sync issue for same upstream SHA is not allowed.
5051

0 commit comments

Comments
 (0)