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.
Arcp::Runtime::JobContext#stream_resultsupports both block and non-block use, but only the block path copieswriter.totalsinto@result_bufferatlib/arcp/runtime/job_context.rb:86throughlib/arcp/runtime/job_context.rb:90. When an agent callswriter = ctx.stream_result, writes chunks, closes the writer, and then callsctx.finish,lib/arcp/runtime/job_context.rb:111indexes the initial array@result_bufferwith:bytesand raisesTypeError: no implicit conversion of Symbol into Integer. Becausefinishsets@donebefore 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#closepersisttotalsback to the context or by havingfinishquery the active writer state when@chunkedis true. Keep the block API behavior unchanged, make repeated close idempotent, and add unit or integration coverage for manual writer use withwriter.write,writer.close, andctx.finishverifyingresult_id,result_size, chunk count, and no unexpectedTypeError.