Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions airbyte/_direct_connectors/connector_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _destination_connections(destination: _DestinationLike) -> list[_ConnectionL
def build_direct_access_sql_guidance(
destination: _DestinationLike,
*,
sql_passthrough_notice: str | None = None,
sql_passthrough_warning: str | None = None,
) -> DirectAccessGuidance:
"""Build standalone sql guidance when there is no associated skill."""
dialect = _SQL_PASSTHROUGH_DESTINATION_DIALECTS[destination.definition_id]
Expand All @@ -215,11 +215,12 @@ def build_direct_access_sql_guidance(
title=f"{destination.name} (SQL passthrough destination)",
summary=f"Table layout and naming for the `{destination.name}` destination.",
tags=["destination"],
warnings=[sql_passthrough_warning] if sql_passthrough_warning else [],
)
connections = _destination_connections(destination)
content: list[dict[str, Any]] = []
if sql_passthrough_notice:
content.append({"type": "paragraph", "text": sql_passthrough_notice})
if sql_passthrough_warning:
content.append({"type": "paragraph", "text": sql_passthrough_warning})
content += _destination_layout_blocks(
destination=destination,
dialect=dialect,
Expand Down Expand Up @@ -247,7 +248,6 @@ def build_direct_access_sql_guidance(
outline=[],
section_id=None,
content=content,
warnings=[sql_passthrough_notice] if sql_passthrough_notice else [],
)


Expand Down
4 changes: 2 additions & 2 deletions airbyte/cloud/connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def get_direct_access_guidance(self, *, section: str | None = None) -> DirectAcc
)
return connector_docs.build_direct_access_sql_guidance(
destination,
sql_passthrough_notice=connector_docs.SQL_PASSTHROUGH_UNAVAILABLE_NOTICE,
sql_passthrough_warning=connector_docs.SQL_PASSTHROUGH_UNAVAILABLE_NOTICE,
)
skill_id = connector_docs.destination_skill_id(self.connector_id)
try:
Expand All @@ -716,7 +716,7 @@ def get_direct_access_guidance(self, *, section: str | None = None) -> DirectAcc
raise
return connector_docs.build_direct_access_sql_guidance(
destination,
sql_passthrough_notice=connector_docs.SQL_PASSTHROUGH_NOT_ENABLED_NOTICE,
sql_passthrough_warning=connector_docs.SQL_PASSTHROUGH_NOT_ENABLED_NOTICE,
)
return connector_docs.merge_destination_skill_docs(server_docs, destination)

Expand Down
12 changes: 10 additions & 2 deletions tests/unit_tests/test_cloud_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
from airbyte._direct_connectors import api_util as agents_api_util
from airbyte._direct_connectors import connector_docs
from airbyte.cloud import workspaces as cloud_workspaces
from airbyte.mcp._docs_results import (
render_agent_skill_docs_result,
render_connector_docs_result,
)
from airbyte.cloud.connections import CloudConnection
from airbyte.cloud.connectors import (
CloudConnector,
Expand Down Expand Up @@ -383,7 +387,9 @@ def test_get_direct_access_guidance_destination_not_enabled_adds_notice(
notice = connector_docs.SQL_PASSTHROUGH_NOT_ENABLED_NOTICE
guidance = destination.get_direct_access_guidance()
assert guidance.content[0] == {"type": "paragraph", "text": notice}
assert guidance.warnings == [notice]
assert guidance.metadata.warnings == [notice]
assert render_connector_docs_result(guidance).warnings == [notice]
assert render_agent_skill_docs_result(guidance).warnings == [notice]
assert guidance.outline == []
assert any(block.get("type") == "table" for block in guidance.content)
assert "execute_external_sql_query" not in _content_text(guidance)
Expand Down Expand Up @@ -520,7 +526,9 @@ def test_get_direct_access_guidance_destination_no_context_layer_notices(
guidance = destination.get_direct_access_guidance()
read_docs.assert_not_called()
assert guidance.content[0] == {"type": "paragraph", "text": notice}
assert guidance.warnings == [notice]
assert guidance.metadata.warnings == [notice]
assert render_connector_docs_result(guidance).warnings == [notice]
assert render_agent_skill_docs_result(guidance).warnings == [notice]
assert guidance.outline == []
assert "execute_external_sql_query" not in _content_text(guidance)
assert "SHOW TABLES" not in _content_text(guidance)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_mcp_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ def test_describe_helper_fallback_guidance_names_no_tools() -> None:
connector = _DescribedConnector(connector_type=ConnectorType.DESTINATION)
connector.guidance = connector_docs.build_direct_access_sql_guidance(
destination,
sql_passthrough_notice=connector_docs.SQL_PASSTHROUGH_NOT_ENABLED_NOTICE,
sql_passthrough_warning=connector_docs.SQL_PASSTHROUGH_NOT_ENABLED_NOTICE,
)

result = _describe(connector, with_direct_access_guidance=True)
Expand Down
Loading