NOJIRA-Aicalls-add-messages-endpoint - #1142
Merged
Merged
Conversation
- bin-ai-manager, bin-api-manager, bin-openapi-manager: Add 8-task TDD implementation plan for the Case Insight Assistant backend fixes
…an review - Fix Task 1/2 gomock expectations (missing PublishWebhookEvent, wrong AIcallUpdate fields, existing test cases broken by the new code path) - Rewrite Tasks 5-7 to match the real flat-struct Test_ServiceAgentAIcallCreate instead of a nonexistent mockSetup-closure convention
…dings - Fix Task 5-7 test cases: set ActiveflowID on non-reused responseAIcall fixtures so the reuse-detection condition doesn't false-positive - Fix Task 1: cover all four pre-existing successful-create test cases, not just two - Resolve Task 8's file-selection ambiguity with a concrete decision - Include regenerated gen.go in the Tasks 5-7 commit
…dings - Fix TimeNow() pointer type mismatch in Task 2's new test (utilHandler.TimeNow() returns *time.Time) - Renumber Task 1/2's new-case UUID prefixes to avoid visual collision with pre-existing cases
…assistance_id in the HTTP handler - Task 4 now fixes server/service_agents_aicalls.go's now-broken direct UUID cast after the openapi spec change, with a request-body-level test proving the omitted field reaches the service handler as uuid.Nil - Add the affected files to the File Structure table
…e both codegen targets - Task 4 now regenerates bin-openapi-manager/gens/models/gen.go in addition to bin-api-manager's copy, in the correct order, per bin-openapi-manager/CLAUDE.md - Add a consumer-safety grep check and update File Structure table + commit file list
…ng type filter field - ai.FieldStruct was silently dropping the 'type' filter, making resolveInsightAIID return any AI instead of only Insight-typed ones - Update File Structure table, Tasks 5-7 commit, and Architecture summary
…type comparison in filters_test.go - ConvertFilters returns the underlying string for named string-kind fields, not the named type; assert against string(ai.TypeInsight)
…n approved - Plan review loop closed after 13 rounds (2 consecutive approvals, rounds 12-13)
…t_case AIcall creation - bin-ai-manager: startReferenceTypeContactCase now starts a pipecatcall and advances to Progressing on genuine creation, matching every other reference type's lifecycle
…tact_case pipecatcall start - bin-ai-manager: In startReferenceTypeContactCase, treat a failed PipecatV1PipecatcallTerminateWithDelay as best-effort (log and continue) instead of returning a hard error, matching the sibling startReferenceTypeConversation. The AIcall row and pipecatcall are already created at that point, so failing the call left the AIcall stuck at StatusInitiating with an orphaned pipecatcall and no scheduled termination. - bin-ai-manager: Add a Debugf log after a successful startPipecatcall call in startReferenceTypeContactCase for observability parity with startReferenceTypeConversation. - bin-ai-manager: Add test coverage for the startPipecatcall error branch and for the corrected log-and-continue behavior of PipecatV1PipecatcallTerminateWithDelay in Test_startReferenceTypeContactCase. - bin-ai-manager: Remove the redundant "starts pipecatcall and advances to progressing" happy-path test case, which duplicated the updated "create succeeds on first attempt" case.
…t Initiating on transient pipecat outage - bin-ai-manager: In startReferenceTypeContactCase, retry the pipecatcall-start sequence when the duplicate-key reuse branch finds an existing row still at StatusInitiating, instead of returning it as-is - bin-ai-manager: Extract the start-pipecatcall + terminate-with-delay + advance-to-Progressing sequence into a shared startContactCaseTurn helper used by both the genuine-create path and the new reuse-retry path - bin-ai-manager: Document that the genuine-create branch intentionally advances to Progressing after starting the pipecatcall, unlike startReferenceTypeConversation - bin-ai-manager: Add a test case covering the Initiating-status reuse-retry path in Test_startReferenceTypeContactCase
…-Initiating retry branch - start.go: top-level Flow doc comment now documents the Initiating-retry sub-branch found in round-4 code review
…case AIcalls instead of reusing forever - bin-ai-manager: startReferenceTypeContactCase now checks isAIcallIdleExpired on the reuse path and explicitly terminates + retries, skipping the recreate rate limit (which does not apply to organic idle expiry)
…er stuck-Initiating retry - bin-ai-manager: Add test case covering a contact_case AIcall row that is both stuck at StatusInitiating and idle-expired, asserting the idle-expiry branch (terminate+recreate) wins over the stuck-Initiating retry branch (resume via startContactCaseTurn) - bin-ai-manager: Add inline comment in startReferenceTypeContactCase documenting that the idle-expiry check runs before, and takes precedence over, the stuck-Initiating retry check
…al increments in idle-expiry tests - start_test.go: add expectIdleExpiredInc field, following the existing expectRateLimitedInc pattern, and assert it on both idle-expiry test cases so a future regression that drops the Inc() call would be caught
- bin-ai-manager: Send() now rejects a new send within aicall_send_cooldown_seconds (default 3s) of the AIcall's last update, bounding LLM spend from rapid repeated sends
…renceTypeCall path - bin-ai-manager: Send() now explicitly refreshes TMUpdate on every successful dispatch (both ReferenceTypeCall and other reference types), so the cooldown actually bounds rapid sends on live-call AIcalls, not just contact_case ones - bin-ai-manager: add test coverage for outside-cooldown success, ReferenceTypeCall cooldown enforcement, and TMUpdate==nil fresh-AIcall pass-through
…y optional for contact_case AI creates - bin-openapi-manager: assistance_id is no longer unconditionally required on POST /service_agents/aicalls -- omit it for assistance_type=ai + reference_type=contact_case to get server-side Insight AI resolution - bin-api-manager: fix the generated-type change's fallout in the HTTP handler (nil-safe assistance_id extraction) and add a request-body-level test proving the omitted field reaches the service handler as uuid.Nil
- bin-api-manager: ServiceAgentAIcallCreate now rejects contact_case references belonging to a foreign customer, resolves assistance_id automatically when omitted for assistance_type=ai + reference_type=contact_case, and deletes its freshly-created activeflow whenever AIV1AIcallStart returns a reused aicall - bin-ai-manager: ai.FieldStruct was silently dropping the type filter, which broke resolveInsightAIID's Insight-only scoping -- add it
… from ownership mismatch - bin-api-manager: ServiceAgentAIcallCreate's contact_case ownership check no longer collapses a ContactV1CaseGet RPC/lookup failure into ErrPermissionDenied -- only an actual customer_id mismatch returns 403, matching the established Get-then-compare idiom used elsewhere in this package (ai.go's RAG check, activeflows.go's flow check)
…tion and send cooldown in RST docs - bin-api-manager: Add RST documentation for the new assistance_id-omitted resolution behavior and the send cooldown on service_agents AIcall endpoints
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.
Make reference_type=contact_case AIcalls behave correctly end-to-end through the existing service_agents API surface, powering the new Case Insight Assistant panel in square-admin without any new backend endpoints.