Skip to content

fix(model): replace inherited output limits on request overrides - #4564

Open
ningmao-hlyz wants to merge 1 commit into
agentscope-ai:mainfrom
ningmao-hlyz:fix/output-limit-override
Open

ningmao-hlyz wants to merge 1 commit into
agentscope-ai:mainfrom
ningmao-hlyz:fix/output-limit-override

Conversation

@ningmao-hlyz

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT, based on main at 634fe8d7.

Description

Fixes #4164.

maxTokens and maxCompletionTokens name one output limit, but mergeOptions fell back per field. A request that set only maxTokens kept maxCompletionTokens from the model defaults, and the reverse. Downstream that means:

  • HarnessContextBuilder.inputLimit and JevRouteCatalog take Math.max of the two, so the inherited default becomes the reserved output budget and the input budget loses that much room.
  • OpenAIChatFormatter.applyMaxTokens writes both non-null fields into the request, so which limit applies depends on the provider.

The fix treats the two fields as one override group:

  • request sets either field: both limits come from the request, the other becomes null;
  • request sets neither: both defaults are kept;
  • request sets both: both are preserved as supplied.

Provider-specific validation is untouched. The Math.max folding in HarnessContextBuilder and JevRouteCatalog stays as it is, because when a caller does supply both limits, reserving the larger one is the conservative choice.

The merge rules in the mergeOptions Javadoc now carry the output-limit entry.

Validation on Windows with Java 17:

mvn -B -o -T1C -pl agentscope-core -Dtest=GenerateOptionsTest,ReActAgentGenerateOptionsTest* test
mvn -B -o -T1C -pl agentscope-core test

The targeted classes pass (51 tests). agentscope-core in full: 3635 tests, 0 failures, 9 skipped. With the source change stashed, the two directional regressions fail (requestMaxTokensReplacesInheritedCompletionLimit and requestCompletionLimitReplacesInheritedMaxTokens, both expected: <null> but was: <16000>), so the tests are not vacuous.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests in agentscope-core are passing (mvn test -pl agentscope-core)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (merge rules in mergeOptions Javadoc)
  • Code is ready for review

maxTokens and maxCompletionTokens name the same output limit, but mergeOptions
fell back per field. A request that set only one of them kept the other from the
model defaults, so the merged options carried two limits and downstream budget
estimation reserved the larger one as output.

Treat the two fields as one override group: a request value in either field
replaces both defaults, a request without either keeps both defaults, and an
explicit pair is preserved as supplied.

This branch has not been deployed

No deployments
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.

[Bug]: Output limits are merged per field and window exhaustion is read as a complete response

1 participant