-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Add Agent Skills support to the Common AI provider #67786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -837,6 +837,7 @@ instanceTemplates | |
| InstanceType | ||
| instanceType | ||
| instantiation | ||
| InstructionPart | ||
| integrations | ||
| ints | ||
| intvl | ||
|
|
||
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
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
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
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
106 changes: 106 additions & 0 deletions
106
providers/common/ai/src/airflow/providers/common/ai/example_dags/example_agent_skills.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| """Example DAGs demonstrating Agent Skills with ``AgentOperator``. | ||
|
|
||
| `Agent Skills <https://agentskills.io>`__ are ``SKILL.md`` bundles the model | ||
| discovers and loads on demand (progressive disclosure). They are passed to the | ||
| agent as an ``AgentSkillsToolset`` in the operator's ``toolsets=`` list. Skill | ||
| sources are resolved when the task runs, on the worker (not while the DAG | ||
| processor parses the file), so a Git token resolved from an Airflow connection | ||
| is never baked into the serialized DAG. | ||
|
|
||
| These DAGs need the optional ``skills`` extra:: | ||
|
|
||
| pip install "apache-airflow-providers-common-ai[skills]" | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from airflow.providers.common.ai.operators.agent import AgentOperator | ||
| from airflow.providers.common.ai.skills import GitSkills | ||
| from airflow.providers.common.ai.toolsets.skills import AgentSkillsToolset | ||
| from airflow.providers.common.ai.toolsets.sql import SQLToolset | ||
| from airflow.providers.common.compat.sdk import dag | ||
|
|
||
| # Skills ship next to this DAG file; resolve relative to __file__ so the path | ||
| # holds regardless of the dag-processor's working directory. | ||
| SKILLS_DIR = Path(__file__).parent / "skills" | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # 1. Local filesystem skills (a directory of SKILL.md bundles) | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| # [START howto_operator_agent_skills_local] | ||
| @dag(tags=["example"]) | ||
| def example_agent_skills_local(): | ||
| AgentOperator( | ||
| task_id="reporter", | ||
| prompt="How many orders did our top 5 customers place last month?", | ||
| llm_conn_id="pydanticai_default", | ||
| system_prompt="You are a data analyst. Consult your skills before writing SQL.", | ||
| toolsets=[ | ||
| AgentSkillsToolset(sources=[str(SKILLS_DIR)]), | ||
| SQLToolset( | ||
| db_conn_id="postgres_default", | ||
| allowed_tables=["customers", "orders"], | ||
| max_rows=50, | ||
| ), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| # [END howto_operator_agent_skills_local] | ||
|
|
||
| example_agent_skills_local() | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # 2. Remote skills from a Git repo, credentials from an Airflow connection | ||
| # --------------------------------------------------------------------------- | ||
| # ``github_skills`` is a git connection (HTTPS token in the password, or an SSH | ||
| # key in the extra). The DAG only references it by id; no credential is inlined. | ||
|
|
||
|
|
||
| # [START howto_operator_agent_skills_git] | ||
| @dag(tags=["example"]) | ||
| def example_agent_skills_git(): | ||
| AgentOperator( | ||
| task_id="support_agent", | ||
| prompt="Summarize our refund policy and apply it to order 12345.", | ||
| llm_conn_id="pydanticai_default", | ||
| system_prompt="You are a support agent. Load the relevant skill before answering.", | ||
| toolsets=[ | ||
| AgentSkillsToolset( | ||
| sources=[ | ||
| GitSkills( | ||
| repo_url="https://github.com/my-org/agent-skills", | ||
| conn_id="github_skills", | ||
| path="skills", | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| # [END howto_operator_agent_skills_git] | ||
|
|
||
| example_agent_skills_git() |
41 changes: 41 additions & 0 deletions
41
...n/ai/src/airflow/providers/common/ai/example_dags/skills/sql-reporting/SKILL.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| name: sql-reporting | ||
| description: Conventions and review steps for writing analytics SQL against the warehouse. Use whenever the task involves querying tables, building a report, or aggregating metrics. | ||
| license: Apache-2.0 | ||
| --- | ||
| <!-- SPDX-License-Identifier: Apache-2.0 | ||
| https://www.apache.org/licenses/LICENSE-2.0 --> | ||
|
|
||
| # SQL Reporting Skill | ||
|
|
||
| Apply this skill before writing or running any analytics SQL so reports stay | ||
| consistent and safe. | ||
|
|
||
| ## When to Use This Skill | ||
|
|
||
| Use this skill when the task involves: | ||
|
|
||
| - Querying warehouse tables for a metric, report, or dashboard figure | ||
| - Aggregating rows (counts, sums, rolling windows) | ||
| - Cross-referencing two or more tables | ||
|
|
||
| ## Conventions | ||
|
|
||
| 1. Always `SELECT` explicit column names, never `SELECT *`. | ||
| 2. Filter on a partition/date column first to bound the scan. | ||
| 3. Alias aggregates with snake_case names (`order_count`, not `count(*)`). | ||
| 4. Cap exploratory queries with `LIMIT` unless an aggregate already collapses | ||
| the result set. | ||
| 5. Prefer `COUNT(DISTINCT ...)` over a sub-query when de-duplicating. | ||
|
|
||
| ## Review Checklist (run before returning an answer) | ||
|
|
||
| - [ ] No `SELECT *`. | ||
| - [ ] A date or partition predicate is present. | ||
| - [ ] Every aggregate has an explicit alias. | ||
| - [ ] The query reads only from tables the task actually needs. | ||
|
|
||
| ## Output Format | ||
|
|
||
| Return the final SQL in a fenced ```sql block, then one sentence describing | ||
| what the query returns. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.