Skip to content

Unbound req in agents/initialize.ts breaks tsc --noEmit on dev #15372

Closed

Description

@danny-avila

Summary

packages/api/src/agents/initialize.ts:984 references a bare req, which has no binding in that scope. npx tsc --noEmit -p packages/api/tsconfig.json on current dev (30124f21b) fails with:

src/agents/initialize.ts(984,7): error TS2304: Cannot find name 'req'.

Cause

Two recent changes collided:

const codeExecutionContext = resolveCodeExecutionContext({
  statefulSessions: effectiveStatefulSessions,
  environment: statefulCodeEnvironment,
  environmentId: agent.code_environment_id,
  environments:
    req.config?.endpoints?.[EModelEndpoint.agents]?.statefulCodeSessions?.environments,  // <-- unbound
  userId: requestFileOwnerId,
  agentId: agent.id,
  conversationId,
});

Suggested fix

The adjacent allowlist read a few lines above already uses appConfig for the same config subtree:

params.allowedStatefulCodeEnvironments ??
  appConfig?.endpoints?.[EModelEndpoint.agents]?.statefulCodeSessions?.allowedEnvironments,

so appConfig is in scope and is the same object:

environments:
  appConfig?.endpoints?.[EModelEndpoint.agents]?.statefulCodeSessions?.environments,

That resolves the type error. Worth confirming it is the intended source, since req.config and appConfig could diverge for request-scoped config — if they can, the value may need threading through params instead.

Impact

Beyond the type error, this is a runtime ReferenceError on any path that reaches it with stateful code sessions configured, since the property access is not optional-chained at req itself.

Found while merging dev into a downstream fork; the file is byte-identical to upstream there, so this is not fork-specific.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions