Skip to content

Preserve result_chunk totals when stream_result returns a writer #29

Description

@nficano

Arcp::Runtime::JobContext#stream_result supports both block and non-block use, but only the block path copies writer.totals into @result_buffer at lib/arcp/runtime/job_context.rb:86 through lib/arcp/runtime/job_context.rb:90. When an agent calls writer = ctx.stream_result, writes chunks, closes the writer, and then calls ctx.finish, lib/arcp/runtime/job_context.rb:111 indexes the initial array @result_buffer with :bytes and raises TypeError: no implicit conversion of Symbol into Integer. Because finish sets @done before building the result, the subsequent error handling path can also fail to publish a clean job error.

Fix prompt: Make the non-block writer path update the context totals before finish, either by letting ChunkWriter#close persist totals back to the context or by having finish query the active writer state when @chunked is true. Keep the block API behavior unchanged, make repeated close idempotent, and add unit or integration coverage for manual writer use with writer.write, writer.close, and ctx.finish verifying result_id, result_size, chunk count, and no unexpected TypeError.

Activity

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

    bugSomething isn't workingseverity:mediumMedium severity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions