Skip to content

forcedotcom/sf-skills / plugins/builder/agentforce-adlc/skills/agentforce-d360-analyze

agentforce-d360-analyze

Verified

Data Cloud 360° view of a single Agentforce session. TRIGGER when user asks to trace, inspect, summarize, or describe a specific Agentforce session by session id (Agent Session UUID `019d…` or MessagingSession id `0Mw…`). Also triggers on session discovery — find/list/search sessions by time, agent, channel, outcome, or conversation text — when the user has no session id yet. DO NOT TRIGGER for design-time architecture questions (use agentforce-architecture-analyze instead) or for runtime perf/latency/SLO questions that require platform telemetry beyond Data Cloud.

FileKindSize
README.mdmarkdown6.2 KB
SKILL.mdskill md13.2 KB
assets/dc/app_generation.sqlother1.9 KB
assets/dc/content_category.sqlother1.5 KB
assets/dc/content_quality.sqlother1.3 KB
assets/dc/discover_sessions.sqlother2.3 KB
assets/dc/feedback.sqlother1.5 KB
assets/dc/feedback_details.sqlother1.3 KB
assets/dc/gateway_records.sqlother1.6 KB
assets/dc/gateway_request_llm.sqlother1.6 KB
assets/dc/gateway_request_metadata.sqlother1.5 KB
assets/dc/gateway_request_tags.sqlother1.4 KB
assets/dc/gateway_requests.sqlother3.4 KB
assets/dc/gateway_responses.sqlother1.7 KB
assets/dc/generations.sqlother1.9 KB
assets/dc/interactions.sqlother2.0 KB
assets/dc/messages.sqlother2.1 KB
assets/dc/messaging_session.sqlother1.7 KB
assets/dc/moment_interactions.sqlother1.4 KB
assets/dc/moments.sqlother1.5 KB
assets/dc/participants.sqlother1.8 KB
assets/dc/sessions.sqlother3.0 KB
assets/dc/steps.sqlother2.6 KB
assets/dc/tag_associations.sqlother1.7 KB
assets/dc/tag_definition_associations.sqlother1.4 KB
assets/dc/tag_definitions.sqlother1.8 KB
assets/dc/tags.sqlother1.3 KB
assets/dc/telemetry_spans.sqlother2.1 KB
references/artifacts.mdmarkdown2.7 KB
references/dc_dmo_fields.mdmarkdown42.1 KB
references/dc_pipeline_contract.mdmarkdown26.3 KB
scripts/_shared/__init__.pyscript122 B
scripts/_shared/cli_override.pyscript3.3 KB
scripts/_shared/fs_guard.pyexecutablescript13.2 KB
scripts/_shared/paths.pyscript5.8 KB
scripts/_shared/runtime.pyscript2.0 KB
scripts/_shared/sql.pyscript548 B
scripts/assemble_dc.pyscript69.6 KB
scripts/config.pyscript1.8 KB
scripts/dc.pyscript13.8 KB
scripts/discover_sessions.pyscript21.1 KB
scripts/fetch_dc.pyscript45.1 KB
scripts/render_dc.pyscript69.7 KB
scripts/resolve_session.pyscript10.8 KB
scripts/storage.pyscript3.1 KB
scripts/tests/__init__.pyscript0 B
scripts/tests/_bootstrap.pyscript483 B
scripts/tests/fixtures/__init__.pyscript0 B
scripts/tests/fixtures/synthetic_session.pyscript14.6 KB
scripts/tests/test_assemble_dc_bootstrap_and_mode.pyscript4.2 KB
scripts/tests/test_assemble_dc_gateway_direct.pyscript8.3 KB
scripts/tests/test_assemble_dc_gateway_direct_integration.pyscript6.4 KB
scripts/tests/test_assemble_dc_helpers.pyscript10.0 KB
scripts/tests/test_assemble_dc_integration.pyscript9.3 KB
scripts/tests/test_dc_and_resolve_session.pyscript26.7 KB
scripts/tests/test_default_target_org.pyscript18.8 KB
scripts/tests/test_discover_sessions.pyscript19.0 KB
scripts/tests/test_discover_sessions_grep_ci.pyscript8.2 KB
scripts/tests/test_fetch_dc_helpers.pyscript10.6 KB
scripts/tests/test_fetch_dc_identity.pyscript22.0 KB
scripts/tests/test_fetch_dc_main.pyscript9.4 KB
scripts/tests/test_fetch_dc_waterfall.pyscript8.6 KB
scripts/tests/test_fetch_dc_waterfall_full.pyscript11.2 KB
scripts/tests/test_identity_coherence.pyscript13.8 KB
scripts/tests/test_render_dc_branches.pyscript9.9 KB
scripts/tests/test_render_dc_gateway_direct.pyscript5.1 KB
scripts/tests/test_render_dc_helpers.pyscript10.5 KB
scripts/tests/test_render_dc_integration.pyscript7.7 KB
scripts/tests/test_render_dc_planner_llm_calls.pyscript11.8 KB
scripts/tests/test_render_dc_show_prompts_gating.pyscript8.7 KB
scripts/tests/test_resolve_from_disk.pyscript4.1 KB
scripts/tests/test_resolve_session_main.pyscript5.2 KB
scripts/tests/test_runtime_override.pyscript4.2 KB
scripts/tests/test_session_shape.pyscript3.5 KB
scripts/tests/test_session_shape_dropped_by_stdm.pyscript3.5 KB
scripts/tests/test_skill_md_prefix_block.pyscript6.8 KB

scripts/tests/test_render_dc_helpers.py

View on GitHub
"""Tests for ``render_dc`` pure-function helpers.

The renderer is large (863 stmts); covering its end-to-end markdown
output requires a complex tree fixture. These tests target the small,
pure helpers — they're cheap to test and account for ~150 stmts of the
gap.
"""
from __future__ import annotations

import unittest
from datetime import datetime, timezone

from . import _bootstrap  # noqa: F401  — sys.path setup

import render_dc  # type: ignore


# -----------------------------------------------------------------------------
# _parse_iso
# -----------------------------------------------------------------------------


class ParseIsoTests(unittest.TestCase):

    def test_returns_none_for_falsy_input(self):
        self.assertIsNone(render_dc._parse_iso(None))
        self.assertIsNone(render_dc._parse_iso(""))

    def test_parses_z_terminated(self):
        self.assertEqual(
            render_dc._parse_iso("2026-04-22T10:00:00Z"),
            datetime(2026, 4, 22, 10, 0, 0, tzinfo=timezone.utc),
        )

    def test_returns_none_for_unparseable(self):
        self.assertIsNone(render_dc._parse_iso("not-a-timestamp"))


# -----------------------------------------------------------------------------
# _fmt_offset
# -----------------------------------------------------------------------------


class FmtOffsetTests(unittest.TestCase):

    def test_returns_dash_when_timestamp_or_start_missing(self):
        anchor = datetime(2026, 4, 22, 10, 0, 0, tzinfo=timezone.utc)
        self.assertEqual(render_dc._fmt_offset(None, anchor), "—")
        self.assertEqual(render_dc._fmt_offset("2026-04-22T10:00:00Z", None), "—")

    def test_formats_offset_with_3_decimals(self):
        anchor = datetime(2026, 4, 22, 10, 0, 0, tzinfo=timezone.utc)
        out = render_dc._fmt_offset("2026-04-22T10:00:01.234Z", anchor)
        self.assertEqual(out, "+1.234s")


# -----------------------------------------------------------------------------
# _fmt_duration_ms
# -----------------------------------------------------------------------------


class FmtDurationMsTests(unittest.TestCase):

    def test_dash_when_either_side_missing(self):
        self.assertEqual(render_dc._fmt_duration_ms(None, "2026-04-22T10:00:00Z"), "—")
        self.assertEqual(render_dc._fmt_duration_ms("2026-04-22T10:00:00Z", None), "—")

    def test_returns_int_ms_with_unit(self):
        out = render_dc._fmt_duration_ms(
            "2026-04-22T10:00:00.000Z", "2026-04-22T10:00:00.123Z",
        )
        self.assertEqual(out, "123ms")


# -----------------------------------------------------------------------------
# _decode + _truncate
# -----------------------------------------------------------------------------


class DecodeTruncateTests(unittest.TestCase):

    def test_decode_unescapes_html_and_collapses_newlines(self):
        self.assertEqual(render_dc._decode(""hi"\nthere"), '"hi" there')

    def test_decode_returns_empty_for_falsy(self):
        self.assertEqual(render_dc._decode(None), "")
        self.assertEqual(render_dc._decode(""), "")

    def test_truncate_pads_with_ellipsis_when_over_n(self):
        long = "a" * 100
        out = render_dc._truncate(long, n=10)
        self.assertEqual(len(out), 10)
        self.assertTrue(out.endswith("…"))

    def test_truncate_returns_input_when_under_or_equal_n(self):
        self.assertEqual(render_dc._truncate("short", n=10), "short")

    def test_truncate_returns_dash_for_falsy(self):
        self.assertEqual(render_dc._truncate(None), "—")
        self.assertEqual(render_dc._truncate(""), "—")


# -----------------------------------------------------------------------------
# _short
# -----------------------------------------------------------------------------


class ShortTests(unittest.TestCase):

    def test_returns_dash_for_falsy(self):
        self.assertEqual(render_dc._short(None), "—")
        self.assertEqual(render_dc._short(""), "—")

    def test_truncates_long_uuid_with_ellipsis(self):
        out = render_dc._short("019dface-0000-7000-8000-000000000001", keep=8)
        self.assertEqual(out, "019dface…")

    def test_returns_input_when_short(self):
        self.assertEqual(render_dc._short("abc"), "abc")


# -----------------------------------------------------------------------------
# _fmt_total_duration — h / m / s rollover
# -----------------------------------------------------------------------------


class FmtTotalDurationTests(unittest.TestCase):

    def test_returns_none_when_either_side_missing(self):
        self.assertIsNone(render_dc._fmt_total_duration(None, "2026-04-22T10:00:00Z"))

    def test_seconds_only(self):
        self.assertEqual(
            render_dc._fmt_total_duration(
                "2026-04-22T10:00:00.000Z", "2026-04-22T10:00:42.500Z",
            ),
            "42.500s",
        )

    def test_minutes_and_seconds(self):
        self.assertEqual(
            render_dc._fmt_total_duration(
                "2026-04-22T10:00:00Z", "2026-04-22T10:02:30Z",
            ),
            "2m 30.000s",
        )

    def test_hours_minutes_seconds(self):
        out = render_dc._fmt_total_duration(
            "2026-04-22T10:00:00Z", "2026-04-22T11:30:45Z",
        )
        self.assertEqual(out, "1h 30m 45.000s")


# -----------------------------------------------------------------------------
# _derive_session_end
# -----------------------------------------------------------------------------


class DeriveSessionEndTests(unittest.TestCase):

    def test_returns_session_end_ts_verbatim_when_present(self):
        end, source = render_dc._derive_session_end(
            {"end_ts": "2026-04-22T11:00:00Z", "interactions": []},
        )
        self.assertEqual(end, "2026-04-22T11:00:00Z")
        self.assertIsNone(source)

    def test_uses_session_end_interaction_start_ts(self):
        sess = {
            "end_ts": None,
            "interactions": [
                {"type": "TURN", "start_ts": "10:00", "end_ts": "10:01"},
                {"type": "SESSION_END", "start_ts": "11:00:00Z"},
            ],
        }
        end, source = render_dc._derive_session_end(sess)
        self.assertEqual(end, "11:00:00Z")
        self.assertEqual(source, "from SESSION_END interaction")

    def test_falls_back_to_last_turn_end_ts(self):
        sess = {
            "end_ts": None,
            "interactions": [
                {"type": "TURN", "start_ts": "10:00", "end_ts": "10:01"},
                {"type": "TURN", "start_ts": "10:02", "end_ts": "10:03"},
            ],
        }
        end, source = render_dc._derive_session_end(sess)
        self.assertEqual(end, "10:03")
        self.assertEqual(source, "session still open (last TURN)")

    def test_returns_none_pair_when_no_data(self):
        end, source = render_dc._derive_session_end({"interactions": []})
        self.assertIsNone(end)
        self.assertIsNone(source)


# -----------------------------------------------------------------------------
# _compose_agent_cell
# -----------------------------------------------------------------------------


class ComposeAgentCellTests(unittest.TestCase):

    def test_full_identity_concatenated(self):
        out = render_dc._compose_agent_cell({
            "agent_api_name": "MyAgent",
            "agent_version": "v3",
            "agent_label": "My Agent",
            "agent_type": "Internal",
        })
        self.assertEqual(out, "MyAgent v3 — My Agent (Internal)")

    def test_only_api_name(self):
        out = render_dc._compose_agent_cell({"agent_api_name": "MyAgent"})
        self.assertEqual(out, "MyAgent")

    def test_only_label(self):
        out = render_dc._compose_agent_cell({"agent_label": "Display Only"})
        self.assertEqual(out, "Display Only")

    def test_returns_none_for_empty_identity(self):
        self.assertIsNone(render_dc._compose_agent_cell({}))


# -----------------------------------------------------------------------------
# _section_session_bootstrap — channel-aware NOT_SET wording
# -----------------------------------------------------------------------------


class SectionSessionBootstrapNotSetWordingTests(unittest.TestCase):
    """`VariableText__c == NOT_SET` is a "no bootstrap variables" signal,
    not a messaging-channel signal. Several non-messaging shapes (E&O
    headless API, Atlas planner, generic API/integration) legitimately
    produce NOT_SET — the rendered line must not call those "production
    messaging path".
    """

    def _identity_with_no_bootstrap(self) -> dict:
        # Sentinel: bootstrap_variables key is present and explicitly None
        # (the assembler stamps None when VariableText__c is NOT_SET).
        return {"bootstrap_variables": None}

    def test_messaging_channel_keeps_messaging_path_addendum(self):
        out = "\n".join(render_dc._section_session_bootstrap(
            self._identity_with_no_bootstrap(),
            channel="SCRT2 - EmbeddedMessaging",
        ))
        self.assertIn("no bootstrap variables", out)
        self.assertIn("production messaging path", out)
        # Alias.
        out2 = "\n".join(render_dc._section_session_bootstrap(
            self._identity_with_no_bootstrap(),
            channel="Messaging",
        ))
        self.assertIn("production messaging path", out2)

    def test_non_messaging_channel_omits_messaging_path(self):
        # E&O is the wheelz that surfaced this bug — Atlas-planner
        # session on the "E & O" channel was being mislabeled
        # "production messaging path".
        out = "\n".join(render_dc._section_session_bootstrap(
            self._identity_with_no_bootstrap(),
            channel="E & O",
        ))
        self.assertIn("no bootstrap variables", out)
        self.assertNotIn("production messaging path", out)
        self.assertNotIn("messaging", out.lower())

    def test_null_channel_uses_neutral_wording(self):
        # No channel info at all — must not assume messaging.
        out = "\n".join(render_dc._section_session_bootstrap(
            self._identity_with_no_bootstrap(),
            channel=None,
        ))
        self.assertIn("no bootstrap variables", out)
        self.assertNotIn("production messaging path", out)

    def test_default_channel_kwarg_is_neutral(self):
        # Backward-compat: callers that don't pass channel get the
        # neutral wording, never the messaging-path label.
        out = "\n".join(render_dc._section_session_bootstrap(
            self._identity_with_no_bootstrap(),
        ))
        self.assertIn("no bootstrap variables", out)
        self.assertNotIn("production messaging path", out)


if __name__ == "__main__":
    unittest.main()
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall