Skip to content

feat: initialize StackOne TypeScript agent with configs and examples - #9

Closed
hiskudin wants to merge 22 commits into
mainfrom
examples/ts-agent
Closed

hiskudin wants to merge 22 commits into
mainfrom
examples/ts-agent

Conversation

@hiskudin

@hiskudin hiskudin commented Jan 26, 2026 •

Copy link
Copy Markdown

This pull request introduces a new TypeScript-based StackOne AI Agent example application that uses the Vercel AI SDK and supports dynamic tool creation from StackOne's MCP endpoint. The agent allows direct tool invocation (without a meta-tool) and features an interactive CLI for user interaction. The implementation includes configuration, dependencies, agent logic, and TypeScript project setup.

The most important changes are:

New Application: StackOne TypeScript Agent

  • Added a new stackone-typescript-agent app, including configuration files (.env.example, package.json, tsconfig.json) and a complete agent implementation in src/agent.ts. [1] [2] [3] [4]

Agent Implementation and Features (src/agent.ts):

  • Implements dynamic discovery and creation of tools for all linked accounts via StackOne MCP, mapping each tool to its account and provider.
  • Provides an interactive CLI mode with conversation history, dynamic provider-aware system prompts, and contextual example queries based on connected services.
  • Integrates with the Vercel AI SDK and Anthropic's Claude model for natural language processing and tool invocation, supporting multi-step workflows and error handling.

Project Configuration and Dependencies:

  • Adds a .env.example for required environment variables, including API keys for StackOne and Anthropic.
  • Sets up package.json with necessary dependencies (@ai-sdk/anthropic, ai, dotenv, zod, etc.) and scripts for running and type-checking the agent.
  • Configures TypeScript via tsconfig.json for strict typing, ES module support, and output settings.

Summary by cubic

Adds a TypeScript StackOne agent example that discovers tools from MCP for each linked account and calls them directly via the Vercel SDK. Includes an interactive CLI with history and a provider-aware system prompt.

  • New Features

    • Discovers tools per linked account via MCP and exposes them as Vercel SDK tools.
    • Namespaces tool keys by provider and account to avoid collisions.
    • Converts MCP JSON Schema to Zod for tool parameters, with a safe fallback for unsupported cases.
    • Direct tool calls (no meta-tool); supports multi-step workflows and error handling.
    • Interactive CLI with conversation history, a /clear command, and dynamic examples.
    • Provider-aware system prompt built from available tools.
  • Dependencies

    • .env.example with STACKONE_API_KEY, STACKONE_ACCOUNT_ID, and ANTHROPIC_API_KEY; optional STACKONE_TOOL_FILTER, MODEL, and STACKONE_BASE_URL.
    • package.json adds required SDKs and scripts: agent, check-types; requires Node >=20.19.6.
    • Strict TypeScript config via tsconfig.json.

Written for commit b525059. Summary will update on new commits.

Copilot AI review requested due to automatic review settings January 26, 2026 10:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new stackone-typescript-agent example app that uses the Vercel AI SDK + Anthropic to dynamically discover StackOne MCP tools and run an interactive CLI agent.

Changes:

  • Added a new TypeScript app with scripts, TS config, and environment variable example.
  • Implemented an interactive CLI agent that discovers linked accounts, lists MCP tools per account, and enables direct tool invocation via generateText.
  • Added dynamic system prompt and example queries based on connected providers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
apps/stackone-typescript-agent/src/agent.ts Implements MCP account/tool discovery, tool execution wiring, prompt building, and CLI loop.
apps/stackone-typescript-agent/package.json Adds dependencies and scripts for running/typechecking the agent.
apps/stackone-typescript-agent/tsconfig.json TypeScript compiler configuration for the new app.
apps/stackone-typescript-agent/.env.example Documents required environment variables for running the agent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +111 to +117
function createVercelTool(mcpTool: McpTool): CoreTool {
const toolName = mcpTool.name;

return {
description: mcpTool.description || `Call the ${toolName} tool`,
parameters: z.record(z.unknown()).describe("Arguments for the tool"),
execute: async (args: Record<string, unknown>) => {

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

McpTool includes inputSchema, but createVercelTool currently uses a generic z.record(z.unknown()) and ignores the provided schema. This loses parameter shape information and removes any validation/guidance for the model. Consider translating inputSchema into a Zod schema when available (and falling back to a permissive schema only when it’s missing).

Copilot uses AI. Check for mistakes.
Comment on lines +174 to +175
toolToAccount.set(mcpTool.name, account.id);
tools[mcpTool.name] = createVercelTool(mcpTool);

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tools[mcpTool.name] and toolToAccount.set(mcpTool.name, …) will silently overwrite when multiple linked accounts expose the same MCP tool name (e.g., two Gmail accounts). That can route tool calls to the wrong account. Consider namespacing tool names (e.g., include account id/provider in the exposed tool name) or storing multiple accounts per tool and requiring disambiguation.

Suggested change
toolToAccount.set(mcpTool.name, account.id);
tools[mcpTool.name] = createVercelTool(mcpTool);
// Ensure tool names are unique across accounts to avoid silent overwrites.
const baseName = mcpTool.name;
let uniqueToolName = baseName;
if (tools[uniqueToolName]) {
// First try namespacing by provider.
uniqueToolName = `${account.provider}_${baseName}`;
}
if (tools[uniqueToolName]) {
// If still colliding (e.g., multiple accounts with same provider),
// append a numeric suffix until we find an available name.
let counter = 2;
let candidate = `${uniqueToolName}_${counter}`;
while (tools[candidate]) {
counter += 1;
candidate = `${uniqueToolName}_${counter}`;
}
uniqueToolName = candidate;
}
toolToAccount.set(uniqueToolName, account.id);
tools[uniqueToolName] = createVercelTool(mcpTool);

Copilot uses AI. Check for mistakes.
tools[mcpTool.name] = createVercelTool(mcpTool);
}

providerCounts[account.provider] = mcpTools.length;

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

providerCounts[account.provider] = mcpTools.length overwrites counts when there are multiple active accounts for the same provider; the summary and system prompt will be inaccurate. Accumulate counts per provider (e.g., providerCounts[provider] = (providerCounts[provider] ?? 0) + mcpTools.length).

Suggested change
providerCounts[account.provider] = mcpTools.length;
providerCounts[account.provider] =
(providerCounts[account.provider] ?? 0) + mcpTools.length;

Copilot uses AI. Check for mistakes.
hiskudin and others added 3 commits January 26, 2026 10:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/stackone-typescript-agent/src/agent.ts">

<violation number="1" location="apps/stackone-typescript-agent/src/agent.ts:105">
P2: Using `||` here discards valid falsy tool results (0/""/false) and returns the wrapper object instead. Use nullish coalescing to preserve legitimate results.</violation>

<violation number="2" location="apps/stackone-typescript-agent/src/agent.ts:174">
P2: Tools from multiple linked accounts can overwrite each other because they’re keyed only by tool name. For users with multiple accounts on the same provider, the last account silently wins and tool calls may be routed to the wrong account.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".gitignore">

<violation number="1" location=".gitignore:40">
P2: Avoid ignoring lock files globally. Lockfiles should be committed so installs are reproducible across machines and CI.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread .gitignore Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +180 to +188
headers: {
Authorization: `Basic ${Buffer.from(STACKONE_API_KEY + ":").toString("base64")}`,
"x-account-id": accountId,
"Content-Type": "application/json",
Accept: "application/json, text/event-stream",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: `req-${method}-${Date.now()}`,

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request advertises Accept: application/json, text/event-stream but the response is always parsed via response.json(). If the server chooses text/event-stream (SSE), this will fail at runtime. Either request only JSON here or add handling for SSE responses.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,22 @@
{
"name": "stackone-typescript-agent",
"version": "1.0.0",

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This app's package.json is missing "private": true. Other example apps in this repo (e.g. apps/oauth-redirect-proxy/package.json) mark themselves private to prevent accidental publication to npm.

Suggested change
"version": "1.0.0",
"version": "1.0.0",
"private": true,

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +9
"scripts": {
"agent": "tsx src/agent.ts",
"typecheck": "tsc --noEmit"
},

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This app defines a typecheck script, but the repo's root uses turbo run check-types (see turbo.json + root package.json). As-is, this app won't participate in the standard type-check task. Rename/add a check-types script (and optionally keep typecheck as an alias) to integrate with the monorepo workflows.

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +74
// For mixed enums, use union of literals
const literals = schema.enum.map((v) => z.literal(v as string | number | boolean));
const zodUnion = z.union(literals as [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]);

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-string enums, this builds a z.union(...) from schema.enum. If the enum has only 1 value (e.g., [1] or [null]), z.union will throw because it requires at least 2 options. Handle single-value enums by returning z.literal(value) (and include null as a supported literal type).

Suggested change
// For mixed enums, use union of literals
const literals = schema.enum.map((v) => z.literal(v as string | number | boolean));
const zodUnion = z.union(literals as [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]);
// For mixed enums, use literals; handle single-value enums without z.union
const literals = schema.enum.map((v) =>
z.literal(v as string | number | boolean | null),
);
if (literals.length === 1) {
const singleLiteral = literals[0];
return schema.description
? singleLiteral.describe(schema.description)
: singleLiteral;
}
const zodUnion = z.union(
literals as [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]],
);

Copilot uses AI. Check for mistakes.
hiskudin and others added 6 commits January 26, 2026 11:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hiskudin hiskudin self-assigned this Jan 27, 2026
StuBehan
StuBehan previously approved these changes Jan 29, 2026

@StuBehan StuBehan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some of the co-pilot comments might be actionable but not gonna block for them

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • apps/stackone-typescript-agent/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +207 to +208
const accountId = toolToAccount.get(toolName);
if (!accountId) {

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callTool() looks up toolToAccount by the tool name it receives. However tools are registered under a namespaced key (provider:accountId:...) while createVercelTool() uses the underlying mcpTool.name. This will cause Unknown tool at runtime. Fix by keying lookups on the registered tool key and keeping a separate mapping for the MCP tool name.

Suggested change
const accountId = toolToAccount.get(toolName);
if (!accountId) {
// First, try direct lookup (in case the map is keyed by the raw tool name)
let accountId = toolToAccount.get(toolName);
// If not found, attempt to resolve by matching the suffix of a namespaced key
if (!accountId) {
for (const [registeredKey, mappedAccountId] of toolToAccount.entries()) {
const registeredName = registeredKey.split(":").pop();
if (registeredName === toolName) {
accountId = mappedAccountId;
break;
}
}
}
if (!accountId) {

Copilot uses AI. Check for mistakes.
Comment on lines +212 to +215
const result = (await mcpRequest(
"tools/call",
{ name: toolName, arguments: args },
accountId

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In tools/call, you send { name: toolName }. If toolName is the namespaced key, MCP will likely not recognize it; if it’s the raw MCP name, it won’t match your toolToAccount keys. Store { accountId, mcpName } per registered tool key and use mcpName in the MCP request.

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +225
*/
function createVercelTool(mcpTool: McpTool): CoreTool {
const toolName = mcpTool.name;

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createVercelTool() binds toolName to mcpTool.name, but the tool is actually exposed to the model under a different key (provider:accountId:...). Pass the exposed tool key into createVercelTool (for logging/description) so what the model calls matches what you display.

Suggested change
*/
function createVercelTool(mcpTool: McpTool): CoreTool {
const toolName = mcpTool.name;
*
* @param mcpTool - The underlying MCP tool definition.
* @param exposedToolKey - The key under which this tool is exposed to the model
* (e.g. "provider:accountId:toolName"). Used for logging
* and descriptions so they match what the model calls.
*/
function createVercelTool(mcpTool: McpTool, exposedToolKey?: string): CoreTool {
const toolName = exposedToolKey ?? mcpTool.name;

Copilot uses AI. Check for mistakes.
Comment on lines +328 to +330
Tool names follow the pattern: provider_action (e.g., gmail_list_messages, drive_list_files).
Use tool names and descriptions to understand their capabilities.
You have conversation history - you can reference previous results.

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The system prompt says tool names follow provider_action (e.g. gmail_list_messages), but the actual registered tool keys are provider:accountId:mcpTool.name. This mismatch can cause the model to call non-existent tools. Update the prompt to describe the real naming scheme (and include an example that matches).

Copilot uses AI. Check for mistakes.
Comment on lines +383 to +385
// Add response to history
conversationHistory.push({ role: "assistant", content: text });

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversation history only persists user/assistant text (conversationHistory.push({ role: "assistant", content: text })) and does not store tool calls/results, but the system prompt claims prior results are available. Persist tool outputs (or a trimmed summary) into conversationHistory after each run so follow-up questions can reference them reliably.

Copilot uses AI. Check for mistakes.
hiskudin and others added 2 commits January 29, 2026 14:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • apps/stackone-typescript-agent/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Authorization: `Basic ${Buffer.from(STACKONE_API_KEY + ":").toString("base64")}`,
"x-account-id": accountId,
"Content-Type": "application/json",
Accept: "application/json, text/event-stream",

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request advertises Accept: application/json, text/event-stream but the response is always parsed via response.json(). If the MCP endpoint responds with text/event-stream (SSE), this will throw. Either remove text/event-stream from Accept or branch on the Content-Type and implement SSE parsing.

Suggested change
Accept: "application/json, text/event-stream",
Accept: "application/json",

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text/event-stream is required when fetching from https://api.stackone.com/mcp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hiskudin

hiskudin commented Jan 29, 2026 •

Copy link
Copy Markdown
Author

Refactored the code and reviewed via Copilot a couple of times; it's definitely cleaner now. Thanks for pointing it out @StuBehan, didn't really look at the comments well.

It seems the merge is still blocked, though. Needs a "reviewer with write access"

/**
* StackOne AI Agent Example - Using Vercel AI SDK
*
* This agent dynamically creates tools from StackOne's MCP endpoint,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we doing this?

This is essentially what the stackone toolset SDK does (create tools from MCP) but also the AI SDK supports MCP servers?

* Convert JSON Schema to Zod schema
* Handles common types and falls back to z.unknown() for unsupported cases
*/
function jsonSchemaToZod(schema: JsonSchema | undefined): z.ZodTypeAny {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this function required, i think the vercel AI SDK can work with json schema https://ai-sdk.dev/docs/reference/ai-sdk-core/json-schema

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • apps/stackone-typescript-agent/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +125 to +131
if (!isInteractive) {
const lines: string[] = [];
for await (const line of rl) {
lines.push(line);
}
for (const line of lines) {
const trimmed = line.trim();

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In non-interactive mode, this buffers all stdin lines into memory before processing. This can be unnecessarily memory-heavy for large inputs; it would be more robust to process each line as it’s read (and close the readline interface when done).

Copilot uses AI. Check for mistakes.
Comment on lines +53 to +62
async function loadTools(): Promise<ToolSet> {
const toolset = new StackOneToolSet({
baseUrl: STACKONE_BASE_URL,
accountId: STACKONE_ACCOUNT_ID,
});

const actions = TOOL_FILTER !== "*" ? [TOOL_FILTER] : undefined;
const tools = await toolset.fetchTools({ actions });
return tools.toAISDK() as unknown as ToolSet;
}

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions dynamic tool creation per linked account, namespacing, and JSON Schema→Zod conversion, but the implementation here just calls StackOneToolSet.fetchTools() and forwards tools.toAISDK(). Please either implement the described behavior or update the PR description so it matches what’s actually being added.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +20
"dependencies": {
"@ai-sdk/anthropic": "^3.0.36",
"@stackone/ai": "^2.3.0",
"ai": "^6.0.69",
"dotenv": "^16.4.0",
"zod": "^3.25.0"
},

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stackone/ai declares an engine requirement of Node >=20.19.6 (see this lockfile’s node_modules/@stackone/ai entry). This app currently doesn’t declare an engines field, and the repo root only requires Node >=18; please add an explicit engines.node constraint here (or otherwise document/enforce the Node version) to prevent runtime/install surprises.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +22
{
"name": "stackone-typescript-agent",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "stackone-typescript-agent",
"version": "1.0.0",
"dependencies": {
"@ai-sdk/anthropic": "^3.0.36",
"@stackone/ai": "^2.3.0",
"ai": "^6.0.69",
"dotenv": "^16.4.0",
"zod": "^3.25.0"
},
"devDependencies": {
"@types/node": "^22.0.0",
"tsx": "^4.19.0",
"typescript": "^5.6.0"
}
},

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo’s other app (apps/oauth-redirect-proxy) doesn’t check in a package-lock.json, but this new app does. To stay consistent and avoid duplicated dependency management in the monorepo, either remove this lockfile or adopt the same lockfile strategy across apps (and document it).

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
STACKONE_API_KEY=your_stackone_api_key
STACKONE_ACCOUNT_ID=your_stackone_account_id

# Optional: filter tools by action pattern (default: "*" loads all)
# STACKONE_TOOL_FILTER=googledrive_*

# Optional: model to use (default: claude-sonnet-4-20250514)
# MODEL=claude-sonnet-4-20250514

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agent.ts reads STACKONE_BASE_URL (defaulting to https://api.stackone.com), but this env var isn’t documented in .env.example. Consider adding it (commented) so users know how to point the agent at non-production environments.

Copilot uses AI. Check for mistakes.
…management. Introduced a new formatError function for better error messages and updated conversationHistory type to enhance type safety.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/stackone-typescript-agent/src/agent.ts">

<violation number="1" location="apps/stackone-typescript-agent/src/agent.ts:17">
P2: Refactoring to a simplified `Message` type (text-only) discards tool execution history (tool calls and results). This prevents the agent from referencing data retrieved in previous turns unless strictly repeated in the final response, degrading multi-turn performance.

Recommended fix: Use `CoreMessage[]` (from Vercel AI SDK) for `conversationHistory` and append all messages from `result.response.messages` to preserve the full conversation context.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@@ -0,0 +1,225 @@
/**

@cubic-dev-ai cubic-dev-ai Bot Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Refactoring to a simplified Message type (text-only) discards tool execution history (tool calls and results). This prevents the agent from referencing data retrieved in previous turns unless strictly repeated in the final response, degrading multi-turn performance.

Recommended fix: Use CoreMessage[] (from Vercel AI SDK) for conversationHistory and append all messages from result.response.messages to preserve the full conversation context.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/stackone-typescript-agent/src/agent.ts, line 17:

<comment>Refactoring to a simplified `Message` type (text-only) discards tool execution history (tool calls and results). This prevents the agent from referencing data retrieved in previous turns unless strictly repeated in the final response, degrading multi-turn performance.

Recommended fix: Use `CoreMessage[]` (from Vercel AI SDK) for `conversationHistory` and append all messages from `result.response.messages` to preserve the full conversation context.</comment>

<file context>
@@ -14,7 +14,8 @@ const TOOL_FILTER = process.env.STACKONE_TOOL_FILTER ?? "*";
 const MAX_HISTORY_TURNS = 10;
 
-const conversationHistory: ModelMessage[] = [];
+type Message = { role: "user" | "assistant"; content: string };
+const conversationHistory: Message[] = [];
 
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants