refactor: Inline single-use helpers in actor_run_response#898
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies follow-up refactors to reduce single-use helpers and unify “empty/nullish” cleaning behavior across the Actor run response and schema generation utilities, while simplifying schema enrichment logic for direct Actor tools.
Changes:
- Renames
removeEmptyArrays→cleanEmptyArraysand updates schema generation + unit tests accordingly. - Reuses
cleanEmptyPropertiesfor Actor run response shaping (inlining prior single-use helpers). - Simplifies
buildEnrichedDirectActorOutputSchemaby cloning the base schema viastructuredCloneand assigning theitemsSchemaleaf.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/schema_generation.test.ts | Updates unit tests to use cleanEmptyArrays name. |
| src/utils/schema_generation.ts | Renames helper and updates schema-generation cleaning path + docs. |
| src/tools/structured_output_schemas.ts | Refactors enriched schema construction using structuredClone and leaf assignment. |
| src/tools/core/actor_run_response.ts | Inlines single-use helpers and switches to cleanEmptyProperties for cleaning. |
| src/tools/common/get_actor_output.ts | Adds cross-link doc comment referencing cleanEmptyArrays. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review nits from #823: - Inline slashToDot (used once) - Inline sleep (used once) - Replace omitNullish with the existing cleanEmptyProperties helper
…blings Behaviour differs (cleanEmptyArrays keeps null/'' to preserve fields for schema inference; cleanEmptyProperties strips everything), so the two helpers stay separate. Align naming under the clean* prefix and add a sibling reference in each docstring.
Use structuredClone + leaf assignment instead of a 6-level nested spread.
9ff607d to
087b160
Compare
MQ37
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #861 — review follow-ups from #823 / #853.
Changes
slashToDot— single call site inbuildRunDatasetsleep— single call site inresolveItemCountWithLagFallbackomitNullish, reusecleanEmptyProperties.removeEmptyArraysrenamed tocleanEmptyArraysfor consistent naming; kept as a separate helper because it deliberately preservesnull/''so schema inference still sees those fields. Cross-link comment added to both functions.buildEnrichedDirectActorOutputSchema— replaced withstructuredClone+ leaf assignment.Behavior
Functionally equivalent.
cleanEmptyPropertiesis stricter thanomitNullishin two edge cases (emptyfields: [], empty-stringname/title) — output schema permits both forms; consumers handle them identically.Verification
pnpm run type-check— cleanpnpm run lint— clean (only pre-existing warnings)pnpm run test:unit— 748 tests pass