Report workspace kind on TUI composer turns (#63545)

## Why

A TUI composer prompt does not supply `workspace_kind`. The app server
can derive it from the thread's current project assignment.

## What changed

Use the staged assignment until the thread is saved, then read the
persisted assignment on each new composer turn. Use `project` or
`projectless` as a fallback for model request metadata and turn analytics.
Explicit client metadata takes precedence, and the inferred value stays
with the originating turn.

## Testing

Cover the model request header and analytics event on the first turn,
on a follow-up, and after removing the project assignment. Unit tests
cover explicit metadata precedence and verify that MCP requests,
extensions, and child agents do not inherit the inferred value.

GitOrigin-RevId: 62b88484dd4028a6b72584999e0fa9b84e6e3b03
This commit is contained in:
marksteinbrick-oai
2026-11-24 05:33:38 +00:00
committed by copyberry
parent a90526e8a7
commit baf9b39b16
7 changed files with 182 additions and 0 deletions
+6
View File
@@ -156,6 +156,7 @@ impl PreparedTurnInputSettings {
kind: TurnStartKind,
) -> CodexResult<Option<Arc<TurnContext>>> {
let TurnStartOptions {
inferred_workspace_kind,
turn_trigger,
final_output_json_schema,
direct_only_tool_namespaces,
@@ -215,6 +216,11 @@ impl PreparedTurnInputSettings {
replacement: Some(inherited_client_metadata),
..Default::default()
});
if let Some(kind) = inferred_workspace_kind {
turn_context
.turn_metadata_state
.set_inferred_workspace_kind(kind);
}
if let Some(turn_trigger) = turn_trigger {
turn_context
.turn_metadata_state