diff --git a/apps/gateway/src/app.ts b/apps/gateway/src/app.ts index 7f12c1f3..91e927cc 100644 --- a/apps/gateway/src/app.ts +++ b/apps/gateway/src/app.ts @@ -109,7 +109,8 @@ app.all(async (ctx) => { } else { originResponse = await createHttpResponseFromMcpToolCallResponse(ctx, { ...resolvedHttpEdgeRequest, - toolCallResponse: resolvedOriginToolCallResult.toolCallResponse + toolCallResponse: resolvedOriginToolCallResult.toolCallResponse, + toolConfig: resolvedOriginToolCallResult.toolConfig }) } diff --git a/apps/gateway/src/lib/create-http-response-from-mcp-tool-call-response.ts b/apps/gateway/src/lib/create-http-response-from-mcp-tool-call-response.ts index c86a324b..f5d45035 100644 --- a/apps/gateway/src/lib/create-http-response-from-mcp-tool-call-response.ts +++ b/apps/gateway/src/lib/create-http-response-from-mcp-tool-call-response.ts @@ -1,4 +1,4 @@ -import type { AdminDeployment, Tool } from '@agentic/platform-types' +import type { AdminDeployment, Tool, ToolConfig } from '@agentic/platform-types' import { assert } from '@agentic/platform-core' import type { GatewayHonoContext, McpToolCallResponse } from './types' @@ -9,11 +9,13 @@ export async function createHttpResponseFromMcpToolCallResponse( { tool, deployment, - toolCallResponse + toolCallResponse, + toolConfig }: { tool: Tool deployment: AdminDeployment toolCallResponse: McpToolCallResponse + toolConfig?: ToolConfig } ): Promise { assert( @@ -29,6 +31,12 @@ export async function createHttpResponseFromMcpToolCallResponse( ) if (tool.outputSchema) { + // eslint-disable-next-line no-console + console.log(`tool call "${tool.name}" structured response:`, { + outputSchema: tool.outputSchema, + toolCallResponse + }) + assert( toolCallResponse.structuredContent, 502, @@ -41,7 +49,8 @@ export async function createHttpResponseFromMcpToolCallResponse( data: toolCallResponse.structuredContent as Record, coerce: false, // TODO: double-check MCP schema on whether additional properties are allowed - strictAdditionalProperties: true, + strictAdditionalProperties: + toolConfig?.outputSchemaAdditionalProperties === false, errorPrefix: `Invalid tool response for tool "${tool.name}"`, errorStatusCode: 502 }) diff --git a/examples/ts-sdks/ai-sdk/bin/weather-experimental-active-tools.ts b/examples/ts-sdks/ai-sdk/bin/weather-experimental-active-tools.ts index cd676204..4acef15f 100644 --- a/examples/ts-sdks/ai-sdk/bin/weather-experimental-active-tools.ts +++ b/examples/ts-sdks/ai-sdk/bin/weather-experimental-active-tools.ts @@ -21,7 +21,7 @@ async function main() { prompt: 'What is the weather in San Francisco?' }) - console.log(result.toolResults[0]) + console.log(JSON.stringify(result.toolResults[0], null, 2)) } await main() diff --git a/examples/ts-sdks/ai-sdk/bin/weather.ts b/examples/ts-sdks/ai-sdk/bin/weather.ts index dd43dfba..c4a335a9 100644 --- a/examples/ts-sdks/ai-sdk/bin/weather.ts +++ b/examples/ts-sdks/ai-sdk/bin/weather.ts @@ -18,7 +18,7 @@ async function main() { prompt: 'What is the weather in San Francisco?' }) - console.log(result.toolResults[0]) + console.log(JSON.stringify(result.toolResults[0], null, 2)) } await main() diff --git a/examples/ts-sdks/genaiscript/calculator.genai.mts b/examples/ts-sdks/genaiscript/calculator.genai.mts deleted file mode 100644 index decd29b4..00000000 --- a/examples/ts-sdks/genaiscript/calculator.genai.mts +++ /dev/null @@ -1,4 +0,0 @@ -import { calculator } from '@agentic/calculator' -defTool(calculator) - -$`Answer the following arithmetic question: How much is 11 + 4? then divide by 3?` diff --git a/todo.md b/todo.md index 2f26e7f0..fcf5301c 100644 --- a/todo.md +++ b/todo.md @@ -26,6 +26,7 @@ - add caching to public projects api endpoints - add support for [`@google/genai`](https://github.com/googleapis/js-genai) tools adapter and examples - fix gateway sentry deployment upload +- add feature about optimized context to marketing site ## TODO: Post-MVP