Repository navigation
fix(server): t3_project_read shows the default model saved in Settings #38636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import { | |
| OrchestratorMcpFailure, | ||
| type OrchestrationV2ThreadLaunchWorkspaceStrategy, | ||
| ProjectId, | ||
| type Project as ProjectRecord, | ||
| T3_PROJECT_FILE_NAME, | ||
| } from "@t3tools/contracts"; | ||
| import * as Digest from "effect/crypto/Digest"; | ||
|
|
@@ -165,6 +166,25 @@ const access = Effect.gen(function* () { | |
| yield* readCaller(); | ||
| return yield* Project.ProjectService; | ||
| }); | ||
|
|
||
| /** Settings, not the project record, hold the project default model that new threads use. */ | ||
| const withSavedDefaultModel = Effect.gen(function* () { | ||
| const settings = yield* ServerSettings.ServerSettingsService.pipe( | ||
| Effect.flatMap((service) => service.getSettings), | ||
| Effect.mapError(unavailable), | ||
| ); | ||
| return (project: ProjectRecord) => { | ||
| const resolved = resolveProjectSettings(settings, project.id, project); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve project defaults in The MCP handler now loads settings and applies project model policy after calling the project service. Put that operation in As per path instructions, “MCP tools are transport handlers: decode the request, call one service method, and map typed errors.”
|
||
| return { | ||
| ...project, | ||
| defaultModelSelection: | ||
| resolved.sources.defaultModelSelection === "project" | ||
| ? resolved.settings.defaultModelSelection | ||
| : null, | ||
| }; | ||
| }; | ||
| }); | ||
|
|
||
| export const layer = McpToolAccess.toLayer(ProjectToolkit, { | ||
| t3_thread_launch: McpToolAccess.startsThreads( | ||
| (input) => input, | ||
|
|
@@ -407,9 +427,10 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, { | |
| Effect.gen(function* () { | ||
| const projects = yield* access; | ||
| // Identities are resolved: linked environments find this side's project by repository. | ||
| return yield* projects | ||
| const page = yield* projects | ||
| .listPage({ cursor: input.cursor ?? 0, limit: input.limit ?? 20 }) | ||
| .pipe(Effect.mapError(unavailable)); | ||
| return { ...page, projects: page.projects.map(yield* withSavedDefaultModel) }; | ||
| }), | ||
| ), | ||
| t3_project_read: McpToolAccess.reads((input) => | ||
|
|
@@ -421,7 +442,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, { | |
| code: "invalid_request", | ||
| message: "The project was not found.", | ||
| }); | ||
| return result.value; | ||
| return (yield* withSavedDefaultModel)(result.value); | ||
| }), | ||
| ), | ||
| t3_project_create: McpToolAccess.writesEnvironment( | ||
|
|
@@ -475,9 +496,10 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, { | |
| t3_project_update: McpToolAccess.writesEnvironment((input) => | ||
| Effect.gen(function* () { | ||
| const projects = yield* Project.ProjectService; | ||
| return yield* projects | ||
| const updated = yield* projects | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Write explicit default model changes to
In the owning service, write explicit model updates and clears to
|
||
| .update({ ...input, commandId: yield* newCommandId() }) | ||
| .pipe(Effect.mapError(projectFailure)); | ||
| return (yield* withSavedDefaultModel)(updated); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not report a committed project update as failed. If the title update commits and the following settings read fails, the tool returns
|
||
| }), | ||
| ), | ||
| t3_project_delete: McpToolAccess.writesEnvironment((input) => | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep project reads independent of unrelated credentials.
On a settings cache miss,
getSettingsreads stored secrets. If an unrelated secret file is unreadable,t3_project_readandt3_project_listnow return an error even when the project query succeeds. A non-linked client still passes MCP authentication in this case. Use a settings read that applies provider policy without loading secret values, so a credential error does not hide the workspace, scripts, or project list. (raw.githubusercontent.com)