@myagentroam/agent 0.9.109 → 0.9.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/main.js CHANGED
@@ -383,6 +383,7 @@ function runtimeModels(models, codexAuthFile) {
383
383
  {
384
384
  ...configuration,
385
385
  responsesEncoding: configuration.responsesEncoding ?? 'STANDARD',
386
+ codexCredential: true,
386
387
  credentialProvider: provider
387
388
  }
388
389
  ];
@@ -11,6 +11,7 @@ export declare function readModelCatalog(home: string): Promise<CliModelCatalog>
11
11
  export declare function writeModelCatalog(home: string, catalog: CliModelCatalog): Promise<void>;
12
12
  export declare function serializeModel(model: CliModelConfiguration): {
13
13
  apiKey: string;
14
+ codexCredential?: boolean;
14
15
  responsesTransport?: import("./configuration.js").ResponsesTransport;
15
16
  responsesPreviousResponseId?: boolean;
16
17
  id: string;
@@ -35,6 +36,7 @@ export declare function serializeModel(model: CliModelConfiguration): {
35
36
  credential: {
36
37
  type: "CODEX_AUTH_FILE";
37
38
  };
39
+ codexCredential?: boolean;
38
40
  responsesTransport?: import("./configuration.js").ResponsesTransport;
39
41
  responsesPreviousResponseId?: boolean;
40
42
  id: string;
@@ -91,6 +91,7 @@ declare const rawModelSchema: z.ZodObject<{
91
91
  export interface MarAgentModelConfiguration extends Omit<z.infer<typeof rawModelSchema>, 'apiKey' | 'responsesPreviousResponseId' | 'responsesTransport'> {
92
92
  apiKey?: SecretValue;
93
93
  credentialProvider?: ModelCredentialProvider;
94
+ codexCredential?: boolean;
94
95
  responsesTransport?: ResponsesTransport;
95
96
  responsesPreviousResponseId?: boolean;
96
97
  }
@@ -65,6 +65,8 @@ export interface ModelRequest {
65
65
  /** Preserve the visible tool catalog while controlling whether the model may call it. */
66
66
  toolChoice?: 'auto' | 'none';
67
67
  reasoningEffort?: MarAgentReasoningEffort;
68
+ /** Stable request-level effort while native configuration updates select the current effort. */
69
+ requestReasoningEffort?: MarAgentReasoningEffort;
68
70
  promptCacheKey?: string;
69
71
  images?: readonly {
70
72
  mimeType: string;
@@ -1,7 +1,7 @@
1
1
  import { isDeepStrictEqual } from 'node:util';
2
2
  import { createHash, randomUUID } from 'node:crypto';
3
3
  import { describeMarAgentError, MarAgentError } from '../error.js';
4
- import { resolveModelDefaultReasoningEffort } from './configuration.js';
4
+ import { marAgentReasoningEffortSchema, resolveModelDefaultReasoningEffort } from './configuration.js';
5
5
  import WebSocket from 'ws';
6
6
  import { isRetryableUpstreamOverloadCode, number, parseSse, record, text } from './sse.js';
7
7
  import { connectSocks5Target, fetchModelResponse, isRetryableModelHttpStatus, isRetryableModelTransportError, modelRetryMaxAttempts, isRetryableModelRequestError, modelRetryDelay, waitForModelRetry } from './http.js';
@@ -887,7 +887,9 @@ function responsesRequestBody(configuration, request, messages, prefixIdentity =
887
887
  include: ['reasoning.encrypted_content'],
888
888
  ...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
889
889
  reasoning: {
890
- effort: request.reasoningEffort?.trim() || resolveModelDefaultReasoningEffort(configuration),
890
+ effort: request.requestReasoningEffort?.trim() ||
891
+ request.reasoningEffort?.trim() ||
892
+ resolveModelDefaultReasoningEffort(configuration),
891
893
  summary: 'auto',
892
894
  ...(lite ? { context: 'all_turns' } : {})
893
895
  }
@@ -1616,7 +1618,20 @@ export function openAiInput(messages, images, modelId, requireEncryptedReasoning
1616
1618
  for (const message of compatibleMessages)
1617
1619
  if (message.role === 'tool_call' && message.inputMode === 'freeform' && message.callId)
1618
1620
  customCallIds.add(message.callId);
1619
- return compatibleMessages
1621
+ const orderedMessages = [];
1622
+ for (const message of compatibleMessages) {
1623
+ if (message.role === 'provider' && message.item?.type === 'configuration_update') {
1624
+ const userIndex = orderedMessages.findLastIndex((candidate) => candidate.role === 'user');
1625
+ if (userIndex >= 0) {
1626
+ orderedMessages.splice(userIndex, 0, message);
1627
+ continue;
1628
+ }
1629
+ }
1630
+ orderedMessages.push(message);
1631
+ }
1632
+ // SDK records the update after the user input; the wire item must precede
1633
+ // that user message so the new effort applies to the response.
1634
+ return orderedMessages
1620
1635
  .filter((message) => !(message.role === 'tool_call' && message.callId && providerCallIds.has(message.callId)) &&
1621
1636
  !(message.role === 'assistant' && providerMessageTexts.has(message.content)))
1622
1637
  .map((message) => openAiInputItem(message, message === lastUser ? images : undefined, customCallIds));
@@ -1626,6 +1641,11 @@ function openAiInputItem(message, images, customCallIds = new Set()) {
1626
1641
  if (message.role === 'provider') {
1627
1642
  if (message.provider !== 'OPENAI_RESPONSES' || !message.item)
1628
1643
  throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Provider context item is invalid.');
1644
+ if (message.item.type === 'configuration_update') {
1645
+ const effort = marAgentReasoningEffortSchema.safeParse(record(message.item.reasoning).effort);
1646
+ if (effort.success)
1647
+ return { type: 'configuration_update', reasoning: { effort: effort.data } };
1648
+ }
1629
1649
  const item = responseItem(message.item);
1630
1650
  if (!item)
1631
1651
  throw new MarAgentError('MAR_AGENT_MODEL_PROTOCOL_ERROR', 'Provider context item type is unsupported.');
package/dist/sdk/agent.js CHANGED
@@ -3,7 +3,7 @@ import { isDeepStrictEqual } from 'node:util';
3
3
  import { describeMarAgentError, MarAgentError } from '../error.js';
4
4
  import { negotiateHost } from '../host/contracts.js';
5
5
  import { AnthropicMessagesAdapter, isAnthropicRecoverableStreamError } from '../model/anthropic-messages.js';
6
- import { resolveModelDefaultReasoningEffort } from '../model/configuration.js';
6
+ import { marAgentReasoningEffortSchema, resolveModelDefaultReasoningEffort } from '../model/configuration.js';
7
7
  import { modelRetryMaxAttempts, isRetryableModelRequestError, waitForModelRetry } from '../model/http.js';
8
8
  import { OpenAiResponsesAdapter, isOpenAiResponsesRecoverableStreamError } from '../model/openai-responses.js';
9
9
  import { AsyncQueue } from '../runtime/async-queue.js';
@@ -400,6 +400,39 @@ export async function createMarAgent(options) {
400
400
  let lastServerUsage = latestModelUsage(contextRecords, selectedModel.id);
401
401
  const compactUserTokenLimit = Math.min(20_000, Math.floor(selectedModel.contextWindowTokens / 8));
402
402
  const reasoningEffort = input.reasoningEffort ?? selectedModel.defaultReasoningEffort;
403
+ const useEffortUpdates = selectedModel.protocol === 'OPENAI_RESPONSES' &&
404
+ selectedModel.responsesEncoding !== 'LITE' &&
405
+ selectedModel.codexCredential === true;
406
+ const previousReasoningEffort = useEffortUpdates
407
+ ? reasoningEffortBaseline(contextRecords, selectedModel.id)
408
+ : undefined;
409
+ let requestReasoningEffort = useEffortUpdates
410
+ ? (previousReasoningEffort ?? reasoningEffort)
411
+ : undefined;
412
+ let effectiveReasoningEffort = useEffortUpdates
413
+ ? previousReasoningEffort === undefined
414
+ ? requestReasoningEffort
415
+ : (lastConfigurationEffort(messages, selectedModel.id) ?? requestReasoningEffort)
416
+ : undefined;
417
+ if (mode !== 'compact' &&
418
+ useEffortUpdates &&
419
+ effectiveReasoningEffort !== reasoningEffort) {
420
+ const update = {
421
+ role: 'provider',
422
+ content: '',
423
+ provider: 'OPENAI_RESPONSES',
424
+ providerModelId: selectedModel.id,
425
+ item: { type: 'configuration_update', reasoning: { effort: reasoningEffort } }
426
+ };
427
+ messages.push(update);
428
+ await store.append(sessionId, {
429
+ type: 'model.context',
430
+ payload: update,
431
+ executionId,
432
+ turnId
433
+ });
434
+ effectiveReasoningEffort = reasoningEffort;
435
+ }
403
436
  if (mode !== 'compact' && subagents)
404
437
  await subagents.beginParentExecution({
405
438
  executionId,
@@ -646,7 +679,7 @@ export async function createMarAgent(options) {
646
679
  tools: executionTools,
647
680
  toolChoice: 'none',
648
681
  promptCacheKey: sessionId,
649
- reasoningEffort,
682
+ reasoningEffort: requestReasoningEffort ?? reasoningEffort,
650
683
  onAttemptDiagnostic: recordModelAttempt('COMPACTION')
651
684
  })) {
652
685
  if (event.type === 'text.completed' &&
@@ -713,6 +746,8 @@ export async function createMarAgent(options) {
713
746
  await persistContextualWorldState(store, sessionId, contextualWorldState);
714
747
  lastServerContextTokens = undefined;
715
748
  lastServerUsage = undefined;
749
+ requestReasoningEffort = reasoningEffort;
750
+ effectiveReasoningEffort = reasoningEffort;
716
751
  await emit({ type: 'context.compacted', compactionId });
717
752
  return true;
718
753
  };
@@ -796,6 +831,7 @@ export async function createMarAgent(options) {
796
831
  : { allowTools: false }),
797
832
  promptCacheKey: sessionId,
798
833
  reasoningEffort,
834
+ ...(requestReasoningEffort === undefined ? {} : { requestReasoningEffort }),
799
835
  ...(modelInputImages?.length ? { images: modelInputImages } : {}),
800
836
  onAttemptDiagnostic: recordModelAttempt(mode === 'compact' ? 'COMPACTION' : 'EXECUTION')
801
837
  })) {
@@ -1756,6 +1792,38 @@ function latestModelUsage(records, selectedModelId) {
1756
1792
  }
1757
1793
  return usage;
1758
1794
  }
1795
+ function reasoningEffortBaseline(records, modelId) {
1796
+ let baseline;
1797
+ for (let index = records.length - 1; index >= 0; index--) {
1798
+ const record = records[index];
1799
+ if (compactSummaryFromCheckpoint(record) !== undefined)
1800
+ break;
1801
+ if (record.type !== 'execution.header')
1802
+ continue;
1803
+ const payload = record.payload;
1804
+ if (payload.modelId !== modelId)
1805
+ break;
1806
+ const effort = marAgentReasoningEffortSchema.safeParse(payload.reasoningEffort);
1807
+ if (effort.success)
1808
+ baseline = effort.data;
1809
+ }
1810
+ return baseline;
1811
+ }
1812
+ function lastConfigurationEffort(messages, modelId) {
1813
+ for (let index = messages.length - 1; index >= 0; index--) {
1814
+ const message = messages[index];
1815
+ if (message.role !== 'provider' ||
1816
+ message.provider !== 'OPENAI_RESPONSES' ||
1817
+ message.providerModelId !== modelId ||
1818
+ message.item?.type !== 'configuration_update')
1819
+ continue;
1820
+ const reasoning = message.item.reasoning;
1821
+ const effort = marAgentReasoningEffortSchema.safeParse(reasoning?.effort);
1822
+ if (effort.success)
1823
+ return effort.data;
1824
+ }
1825
+ return undefined;
1826
+ }
1759
1827
  function shouldUseNativeCompaction(input) {
1760
1828
  if (input.estimatedRequestTokens <= input.contextWindowTokens)
1761
1829
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/agent",
3
- "version": "0.9.109",
3
+ "version": "0.9.110",
4
4
  "description": "Embeddable MAR coding agent SDK and CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",