Skip to content

fix: handle multi-value custom fields in AI context builder#129

Merged
ManukMinasyan merged 1 commit intomainfrom
fix/multi-value-custom-field-context-builder
Feb 16, 2026
Merged

fix: handle multi-value custom fields in AI context builder#129
ManukMinasyan merged 1 commit intomainfrom
fix/multi-value-custom-field-context-builder

Conversation

@ManukMinasyan
Copy link
Contributor

Summary

  • Prevent "Array to string conversion" when RecordContextBuilder returns array values for multi-value fields like domains
  • Add implode() handling in both RecordContextBuilder::getCompanyBasicInfo() and RecordSummaryService::addBasicInfo()
  • Add regression test covering multi-value custom fields in context builder output

Test plan

  • php artisan test --compact tests/Feature/AI/RecordSummaryServiceTest.php — 17 passed

Prevent "Array to string conversion" when RecordContextBuilder returns
array values for multi-value fields like domains. Add implode() in both
RecordContextBuilder and RecordSummaryService, with a regression test.
Copilot AI review requested due to automatic review settings February 16, 2026 19:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes AI context/prompt building when custom fields return multi-value arrays (e.g., company domains), preventing “Array to string conversion” errors and ensuring consistent string output for basic info.

Changes:

  • Convert multi-value domains custom field values into a comma-separated string in RecordContextBuilder::getCompanyBasicInfo().
  • Add defensive array-to-string conversion in RecordSummaryService::addBasicInfo() when formatting the prompt.
  • Add a regression test asserting multi-value company domains are emitted as a string in basic_info.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/Feature/AI/RecordSummaryServiceTest.php Adds regression coverage for multi-value custom field output in the context builder.
app/Services/AI/RecordSummaryService.php Prevents array-to-string conversion errors when basic info values are arrays during prompt formatting.
app/Services/AI/RecordContextBuilder.php Ensures company domains are rendered as a comma-separated string in basic_info.

@ManukMinasyan ManukMinasyan merged commit bbe10fb into main Feb 16, 2026
15 checks passed
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.

1 participant