Files
agents/tsdown.config.mjs
d5ed11678a feat(openai): persist GPT-5.6 Responses state (inherit upstream converter) (#303)
* feat(openai): persist GPT-5.6 Responses state (inherit upstream converter)

Slim reimplementation of #301. Keeps the genuinely fork-specific deltas —
managed prompt-cache breakpoints (prompt_cache_options + breakpoint
injection), safety_identifier, cache-write usage metadata, and the
encrypted-reasoning `include` request (shouldIncludeEncryptedReasoning) —
but INHERITS @langchain/openai's convertMessagesToResponsesInput for the
reasoning replay / encrypted_content / response.output reuse instead of
forking it, avoiding permanent converter parity divergence.

Breakpoints are injected over upstream's converter output at
completionWithRetry; cache-write is surfaced by thin _generate/
_streamResponseChunks wraps over super. Bumps @langchain/openai to 1.5.5.

Co-authored-by: Joseph Licata <[email protected]>

* fix: address Codex review on GPT-5.6 managed cache

- Responses breakpoints: only mark input_text/input_image/input_file blocks
  (output_text/refusal are rejected 400 on replayed assistant turns), and
  handle string message content by wrapping it in an input_text breakpoint
  block. Mirrors the Chat Completions breakpoint robustness.
- Drop `npm run build` from the `prepare` script — npm runs prepare during
  `npm pack`, which the publish workflow runs after `npm prune --production`,
  so the build would fail with dev deps removed.

* fix: address Codex round-2 review on GPT-5.6 managed cache

- Never select assistant/tool turns for Responses breakpoints (role gate);
  input_text under role:assistant is rejected 400. Fixes a regression from the
  round-1 string-content wrapping.
- Guard missing input_tokens_details with optional chaining so non-cache
  Responses/Azure usage (top-level counts only) doesn't throw.
- Expose promptCacheExplicit/safety_identifier on Azure options via a shared
  ManagedRequestOptions type (the Azure wrappers read them).
- Bump declared @langchain/core to ^1.2.2 to match @langchain/openai 1.5.5's
  peer floor.

---------

Co-authored-by: Joseph Licata <[email protected]>
2026-07-13 08:22:12 -04:00

52 lines
2.1 KiB
JavaScript

import { defineConfig } from 'tsdown';
import { isAbsolute } from 'node:path';
const entry = {
main: 'src/index.ts',
'openai/index': 'src/openai/index.ts',
'responses/index': 'src/responses/index.ts',
'langchain/index': 'src/langchain/index.ts',
'langchain/google-common': 'src/langchain/google-common.ts',
'langchain/language_models/chat_models':
'src/langchain/language_models/chat_models.ts',
'langchain/messages': 'src/langchain/messages.ts',
'langchain/messages/tool': 'src/langchain/messages/tool.ts',
'langchain/openai': 'src/langchain/openai.ts',
'langchain/prompts': 'src/langchain/prompts.ts',
'langchain/runnables': 'src/langchain/runnables.ts',
'langchain/tools': 'src/langchain/tools.ts',
'langchain/utils/env': 'src/langchain/utils/env.ts',
};
const shared = {
entry,
platform: 'node',
// Declarations are emitted separately by `tsc -p tsconfig.build.json` (see the
// `build` script); the source isn't isolatedDeclarations-clean, so oxc dts
// isn't viable yet and tsc keeps the exact same dist/types output as before.
dts: false,
sourcemap: true,
// Mirror Rollup's `preserveModules: true` — one output file per source module,
// preserving the src-relative paths the package.json exports map points at.
unbundle: true,
// Force `.mjs`/`.cjs` regardless of package `type`, matching the previous
// Rollup `entryFileNames` and the paths in the exports map.
fixedExtension: true,
alias: { '@': './src' },
// CI greps the build output for "Circular depend" (validate.yml); rolldown's
// check is off by default, so enable it to keep that guard working.
inputOptions: { checks: { circularDependency: true } },
// Match the prior Rollup build (`external: [/node_modules/]`): bundle nothing
// third-party, compile only this package's own modules.
deps: {
neverBundle: (id) =>
!id.startsWith('.') && !id.startsWith('@/') && !isAbsolute(id),
onlyBundle: false,
},
};
export default defineConfig([
{ ...shared, format: 'esm', outDir: 'dist/esm' },
{ ...shared, format: 'cjs', outDir: 'dist/cjs' },
]);