Skip to content

Commit 3626411

Browse files
committed
feat(org-detection): parse agent responses better
1 parent 3a07d77 commit 3626411

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/agents/org-detector/agent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ Output absolutely no text except for that final JSON.
343343
return noFoundFallback;
344344
}
345345

346-
const finalText = lastMsg.content.trim();
346+
let finalText = lastMsg.content.trim();
347+
finalText = finalText.startsWith('```json') ? finalText.slice(7, -3) : finalText;
347348

348349
try {
349350
const parsed = JSON.parse(finalText);

src/support/slack/actions/approve-site-candidate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from '@adobe/spacecat-shared-data-access';
1818
import { BaseSlackClient, SLACK_TARGETS } from '@adobe/spacecat-shared-slack-client';
1919
import { Blocks, Elements, Message } from 'slack-block-builder';
20+
import { hasText } from '@adobe/spacecat-shared-utils';
2021
import { BUTTON_LABELS } from '../../../controllers/hooks.js';
2122
import { composeReply, extractURLFromSlackMessage } from './commons.js';
2223
import { getHlxConfigMessagePart } from '../../../utils/slack/base.js';
@@ -124,7 +125,7 @@ export default function approveSiteCandidate(lambdaContext) {
124125

125126
log.info(`Detected org: ${JSON.stringify(org)}`);
126127

127-
if (org) {
128+
if (hasText(org?.name) && hasText(org?.imsOrgId)) {
128129
const { name, imsOrgId } = org;
129130

130131
const orgMsg = Message()

0 commit comments

Comments
 (0)