Signals

Signals for the llmtool app.

Each module holds the signals of one kind of work, and this package re-exports them all, so that from smarter.apps.llmtool.signals import plugin_called works for every signal.

Plugin lifecycle

Signals of the lifecycle of every plugin: create, clone, update, delete, select and call.

smarter.apps.llmtool.signals.plugin.broker_ready = <django.dispatch.dispatcher.Signal object>

Signal sent when a broker achieves a ready state.

Parameters:

broker – The broker instance that is ready.

Example:

# a broker sends it once, from its ready property
self.send_broker_ready(broker_ready)
smarter.apps.llmtool.signals.plugin.plugin_called = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin is called.

Parameters:
  • plugin – The plugin instance that was called.

  • inquiry_type – The type of inquiry made to the plugin.

Example:

plugin_called.send(
    sender=self.tool_call_fetch_plugin_response,
    plugin=self,
    inquiry_type=inquiry_type,
)
smarter.apps.llmtool.signals.plugin.plugin_cloned = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin is cloned.

Parameters:

plugin – The plugin instance that was cloned.

Example:

plugin_cloned.send(sender=self.__class__, plugin=self)
smarter.apps.llmtool.signals.plugin.plugin_created = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin is created.

Parameters:

plugin – The plugin instance that was created.

Example:

plugin_created.send(sender=self.__class__, plugin=self)
smarter.apps.llmtool.signals.plugin.plugin_deleted = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin is deleted.

Parameters:
  • plugin – The plugin instance that was deleted.

  • plugin_meta – The plugin meta information.

  • plugin_name – The name of the plugin.

Example:

plugin_deleted.send(
    sender=self.__class__, plugin=self, plugin_meta=self.plugin_meta, plugin_name=plugin_name
)
smarter.apps.llmtool.signals.plugin.plugin_deleting = <django.dispatch.dispatcher.Signal object>

Signal sent before a plugin is deleted.

Parameters:
  • plugin – The plugin instance that is about to be deleted.

  • plugin_meta – The plugin meta information.

Example:

plugin_deleting.send(sender=self.__class__, plugin=self, plugin_meta=self.plugin_meta)
smarter.apps.llmtool.signals.plugin.plugin_ready = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin achieves a ready state.

Parameters:

plugin – The plugin instance that is ready.

Example:

plugin_ready.send(sender=self.__class__, plugin=self)
smarter.apps.llmtool.signals.plugin.plugin_responded = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin responds.

Parameters:
  • plugin – The plugin instance that responded.

  • inquiry_type – The type of inquiry made to the plugin.

  • response – The response returned by the plugin.

Example:

plugin_responded.send(
    sender=self.tool_call_fetch_plugin_response,
    plugin=self,
    inquiry_type=inquiry_type,
    response=retval,
)
smarter.apps.llmtool.signals.plugin.plugin_selected = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin is selected for use.

That is, when the Plugin selection logic results in this Plugin being included in the set of Plugins to be presented to the LLM for a given text completion request.

Parameters:
  • plugin – The plugin instance that was selected.

  • user – The user who selected the plugin (optional).

  • input_text – The input text provided to the plugin (optional).

  • search_term – The search term associated with the plugin selection (optional).

Example:

plugin_selected.send(
    sender=self.selected,
    plugin=self,
    user=self.user_profile.cached_user if self.user_profile else None,
    input_text=input_text,
    search_term=search_term,
)
smarter.apps.llmtool.signals.plugin.plugin_updated = <django.dispatch.dispatcher.Signal object>

Signal sent when a plugin is updated.

Example:

plugin_updated.send(sender=self.__class__, plugin=self)
smarter.apps.llmtool.signals.plugin.search_term_matched = <django.dispatch.dispatcher.Signal object>

Signal sent when smarter.apps.llmtool.nlp.does_refer_to() finds that a prompt refers to a search term.

Plugin selectors use it to decide whether to select a plugin, so this reports why each plugin was selected, and how often each kind of matching (exact, typo tolerant, thesaurus) succeeds.

Parameters:
  • prompt – The prompt, as given to does_refer_to().

  • search_term – The search term that the prompt refers to.

  • method – How it matched, a smarter.apps.llmtool.nlp.MatchMethod: exact, fuzzy or thesaurus.

  • matched_text – For thesaurus matches, the words of the prompt that matched, e.g. a synonym. Otherwise None.

Example:

search_term_matched.send(
    sender=does_refer_to,
    prompt="I want to buy an automobile",
    search_term="car",
    method="thesaurus",
    matched_text="automobile",
)

WebsearchPlugin

Signals of WebsearchPlugin searches and page reads.

smarter.apps.llmtool.signals.websearch.websearch_failed = <django.dispatch.dispatcher.Signal object>

Signal sent when a WebsearchPlugin cannot perform a search or read a web page.

Experimental.

Parameters:
  • plugin – The WebsearchPlugin instance.

  • operation – search or fetch.

  • target – The search query or URL.

  • error – A description of the error, which is also returned to the LLM.

Example:

websearch_failed.send(sender=self.__class__, plugin=self, operation="fetch", target=url, error="HTTP 404")
smarter.apps.llmtool.signals.websearch.websearch_fetched = <django.dispatch.dispatcher.Signal object>

Signal sent when a WebsearchPlugin reads a web page.

Experimental.

Parameters:
  • plugin – The WebsearchPlugin instance.

  • url – The requested URL.

  • final_url – The URL of the page that was read, after any redirects.

  • characters – The number of characters of content returned to the LLM.

  • truncated – True if the content was truncated.

  • cached – True if the page was served from the cache.

Example:

websearch_fetched.send(sender=self.__class__, plugin=self, url=url, final_url=final_url, characters=1234, truncated=False, cached=False)
smarter.apps.llmtool.signals.websearch.websearch_searched = <django.dispatch.dispatcher.Signal object>

Signal sent when a WebsearchPlugin searches the web.

Experimental.

Parameters:
  • plugin – The WebsearchPlugin instance.

  • query – The search query.

  • provider – The web search API, e.g. brave.

  • result_count – The number of results returned to the LLM.

  • cached – True if the results were served from the cache.

Example:

websearch_searched.send(sender=self.__class__, plugin=self, query=query, provider="brave", result_count=5, cached=False)

Extensions

Signals of Smarter Extensions: installation, and calls to their tools.

smarter.apps.llmtool.signals.extension.extension_disabled = <django.dispatch.dispatcher.Signal object>

Signal sent after an extension is disabled.

Parameters:
  • extension – The Extension.

  • reason – Why it was disabled, e.g. a lifecycle hook failed, or an administrator disabled it.

Example:

extension_disabled.send(sender=self.__class__, extension=extension, reason="disabled by admin")
smarter.apps.llmtool.signals.extension.extension_enabled = <django.dispatch.dispatcher.Signal object>

Signal sent after an extension is enabled.

Parameters:

extension – The Extension.

Example:

extension_enabled.send(sender=self.__class__, extension=extension)
smarter.apps.llmtool.signals.extension.extension_installed = <django.dispatch.dispatcher.Signal object>

Signal sent after an extension is installed for the first time.

Parameters:
  • extension – The Extension.

  • version – The ExtensionVersion that was installed.

Example:

extension_installed.send(sender=self.__class__, extension=extension, version=version)
smarter.apps.llmtool.signals.extension.extension_tool_called = <django.dispatch.dispatcher.Signal object>

Signal sent when an LLM calls one of an extension’s tools.

Parameters:
  • slug – The extension’s slug.

  • version – The extension’s version.

  • tool_name – The tool’s name.

  • arguments – The arguments the LLM sent.

Example:

extension_tool_called.send(sender=self.__class__, slug="weather", version="1.0.0", tool_name="get_weather", arguments={})
smarter.apps.llmtool.signals.extension.extension_tool_completed = <django.dispatch.dispatcher.Signal object>

Signal sent when a call to one of an extension’s tools ends, successfully or not.

It is always the last signal of the call.

Parameters:
  • slug – The extension’s slug.

  • version – The extension’s version.

  • tool_name – The tool’s name.

  • success – False if extension_tool_failed was sent.

  • duration – The seconds that the call took.

Example:

extension_tool_completed.send(sender=self.__class__, slug="weather", version="1.0.0", tool_name="get_weather", success=True, duration=0.8)
smarter.apps.llmtool.signals.extension.extension_tool_failed = <django.dispatch.dispatcher.Signal object>

its arguments are invalid, it raises, or it times out.

Parameters:
  • slug – The extension’s slug.

  • version – The extension’s version.

  • tool_name – The tool’s name.

  • error – What went wrong.

Example:

extension_tool_failed.send(sender=self.__class__, slug="weather", version="1.0.0", tool_name="get_weather", error="timed out")
Type:

Signal sent when one of an extension’s tools fails

smarter.apps.llmtool.signals.extension.extension_tool_responded = <django.dispatch.dispatcher.Signal object>

Signal sent when one of an extension’s tools returns a result.

Parameters:
  • slug – The extension’s slug.

  • version – The extension’s version.

  • tool_name – The tool’s name.

  • characters – The length of the result, as JSON.

  • cached – True if the result came from the cache, without running the tool. See cache_ttl.

Example:

extension_tool_responded.send(sender=self.__class__, slug="weather", version="1.0.0", tool_name="get_weather", characters=1024, cached=False)
smarter.apps.llmtool.signals.extension.extension_uninstalled = <django.dispatch.dispatcher.Signal object>

Signal sent after an extension is uninstalled.

Parameters:

slug – The slug of the extension that was uninstalled.

Example:

extension_uninstalled.send(sender=self.__class__, slug="weather")
smarter.apps.llmtool.signals.extension.extension_upgraded = <django.dispatch.dispatcher.Signal object>

Signal sent after an installed extension’s version changes, by an update or a rollback.

Parameters:
  • extension – The Extension.

  • version – The ExtensionVersion that now runs.

  • previous_version – The version string that it replaced.

Example:

extension_upgraded.send(sender=self.__class__, extension=extension, version=version, previous_version="1.0.0")

SqlPlugin

Signals of SqlPlugin tool calls.

smarter.apps.llmtool.signals.sql.sql_plugin_authenticated = <django.dispatch.dispatcher.Signal object>

Signal sent when the plugin’s SqlConnection connects to its database, which includes authenticating to it.

Not sent when the result is served from the cache.

Parameters:
  • plugin – The SqlPlugin instance.

  • connection – The name of the SqlConnection.

Example:

sql_plugin_authenticated.send(sender=self.__class__, plugin=self, connection="stackademy")
smarter.apps.llmtool.signals.sql.sql_plugin_authentication_failed = <django.dispatch.dispatcher.Signal object>

its credentials are rejected, or the database, or its SSH tunnel, cannot be reached.

The database drivers do not tell these apart.

Parameters:
  • plugin – The SqlPlugin instance.

  • connection – The name of the SqlConnection.

  • error – What went wrong.

Example:

sql_plugin_authentication_failed.send(sender=self.__class__, plugin=self, connection="stackademy", error="could not connect to the database")
Type:

Signal sent when the plugin’s SqlConnection cannot connect to its database

smarter.apps.llmtool.signals.sql.sql_plugin_failed = <django.dispatch.dispatcher.Signal object>

Signal sent when a SqlPlugin tool call fails, whether it raises or returns an empty response to the LLM.

Parameters:
  • plugin – The SqlPlugin instance.

  • error – What went wrong. It never contains credentials.

Example:

sql_plugin_failed.send(sender=self.__class__, plugin=self, error="SQL query failed")
smarter.apps.llmtool.signals.sql.sql_plugin_request_completed = <django.dispatch.dispatcher.Signal object>

Signal sent when a SqlPlugin tool call ends, successfully or not.

It is always the last signal of the call.

Parameters:
  • plugin – The SqlPlugin instance.

  • success – False if sql_plugin_failed was sent.

  • duration – The seconds that the tool call took.

Example:

sql_plugin_request_completed.send(sender=self.__class__, plugin=self, success=True, duration=0.42)
smarter.apps.llmtool.signals.sql.sql_plugin_request_started = <django.dispatch.dispatcher.Signal object>

a SQL query.

Parameters:
  • plugin – The SqlPlugin instance.

  • function_args – The tool call’s arguments, as the LLM sent them.

Example:

sql_plugin_request_started.send(sender=self.__class__, plugin=self, function_args=function_args)
Type:

Signal sent when a SqlPlugin tool call begins

smarter.apps.llmtool.signals.sql.sql_plugin_responded = <django.dispatch.dispatcher.Signal object>

Signal sent when a SqlPlugin tool call returns its response to the LLM.

Parameters:
  • plugin – The SqlPlugin instance.

  • response – The query result, as a JSON string, or an empty string if the query returned no rows.

  • cached – True if the result was served from the cache.

  • sql – The SQL query, with the arguments interpolated.

Example:

sql_plugin_responded.send(sender=self.__class__, plugin=self, response='[{"course_code": "CS101"}]', cached=False, sql="SELECT ...;")

ApiPlugin

Signals of ApiPlugin tool calls.

smarter.apps.llmtool.signals.api.api_plugin_authenticated = <django.dispatch.dispatcher.Signal object>

Signal sent when the plugin’s remote API accepts the request’s credentials, that is, responds with any status other than HTTP 401 or 403.

Not sent when the response is served from the cache.

Parameters:
  • plugin – The ApiPlugin instance.

  • connection – The name of the ApiConnection.

  • auth_method – The ApiConnection’s authentication method, e.g. none, basic or token.

  • status_code – The HTTP status code of the response.

Example:

api_plugin_authenticated.send(sender=self.__class__, plugin=self, connection="stackademy", auth_method="token", status_code=200)
smarter.apps.llmtool.signals.api.api_plugin_authentication_failed = <django.dispatch.dispatcher.Signal object>

Signal sent when the plugin’s remote API rejects the request’s credentials, with HTTP 401 or 403.

Parameters:
  • plugin – The ApiPlugin instance.

  • connection – The name of the ApiConnection.

  • auth_method – The ApiConnection’s authentication method.

  • status_code – The HTTP status code of the response.

  • error – What went wrong.

Example:

api_plugin_authentication_failed.send(sender=self.__class__, plugin=self, connection="stackademy", auth_method="token", status_code=401, error="HTTP 401")
smarter.apps.llmtool.signals.api.api_plugin_failed = <django.dispatch.dispatcher.Signal object>

Signal sent when a ApiPlugin tool call fails, whether it raises or returns an empty response to the LLM.

Parameters:
  • plugin – The ApiPlugin instance.

  • error – What went wrong. It never contains credentials.

Example:

api_plugin_failed.send(sender=self.__class__, plugin=self, error="API request failed: GET /v1/courses/")
smarter.apps.llmtool.signals.api.api_plugin_request_completed = <django.dispatch.dispatcher.Signal object>

Signal sent when a ApiPlugin tool call ends, successfully or not.

It is always the last signal of the call.

Parameters:
  • plugin – The ApiPlugin instance.

  • success – False if api_plugin_failed was sent.

  • duration – The seconds that the tool call took.

Example:

api_plugin_request_completed.send(sender=self.__class__, plugin=self, success=True, duration=0.42)
smarter.apps.llmtool.signals.api.api_plugin_request_started = <django.dispatch.dispatcher.Signal object>

a remote API request.

Parameters:
  • plugin – The ApiPlugin instance.

  • function_args – The tool call’s arguments, as the LLM sent them.

Example:

api_plugin_request_started.send(sender=self.__class__, plugin=self, function_args=function_args)
Type:

Signal sent when a ApiPlugin tool call begins

smarter.apps.llmtool.signals.api.api_plugin_responded = <django.dispatch.dispatcher.Signal object>

Signal sent when a ApiPlugin tool call returns its response to the LLM.

Parameters:
  • plugin – The ApiPlugin instance.

  • response – The JSON response, as a dict or list, or an empty string if it was empty.

  • cached – True if the response was served from the cache.

  • method – The HTTP method.

  • endpoint – The endpoint, with its placeholders interpolated.

Example:

api_plugin_responded.send(sender=self.__class__, plugin=self, response=[{"id": 1}], cached=False, method="GET", endpoint="/v1/courses/")

SkillPlugin

Signals of SkillPlugin tool calls, and the retrieval of remote skills.

smarter.apps.llmtool.signals.skill.skill_plugin_failed = <django.dispatch.dispatcher.Signal object>

Signal sent when a SkillPlugin tool call fails, whether it raises or returns an empty response to the LLM.

Parameters:
  • plugin – The SkillPlugin instance.

  • error – What went wrong. It never contains credentials.

Example:

skill_plugin_failed.send(sender=self.__class__, plugin=self, error="resource not found: assets/missing.md")
smarter.apps.llmtool.signals.skill.skill_plugin_request_completed = <django.dispatch.dispatcher.Signal object>

Signal sent when a SkillPlugin tool call ends, successfully or not.

It is always the last signal of the call.

Parameters:
  • plugin – The SkillPlugin instance.

  • success – False if skill_plugin_failed was sent.

  • duration – The seconds that the tool call took.

Example:

skill_plugin_request_completed.send(sender=self.__class__, plugin=self, success=True, duration=0.42)
smarter.apps.llmtool.signals.skill.skill_plugin_request_started = <django.dispatch.dispatcher.Signal object>

a request for the skill’s instructions, or one of its bundled files.

Parameters:
  • plugin – The SkillPlugin instance.

  • function_args – The tool call’s arguments, as the LLM sent them.

Example:

skill_plugin_request_started.send(sender=self.__class__, plugin=self, function_args=function_args)
Type:

Signal sent when a SkillPlugin tool call begins

smarter.apps.llmtool.signals.skill.skill_plugin_responded = <django.dispatch.dispatcher.Signal object>

Signal sent when a SkillPlugin tool call returns its response to the LLM.

Parameters:
  • plugin – The SkillPlugin instance.

  • response – The skill’s instructions, or the bundled file.

  • cached – Always False. A SkillPlugin reads the skill that was stored when its manifest was applied.

  • resource – The bundled file that was requested, or None for the instructions.

Example:

skill_plugin_responded.send(sender=self.__class__, plugin=self, response={"instructions": "..."}, cached=False, resource="assets/template.md")
smarter.apps.llmtool.signals.skill.skill_plugin_retrieval_failed = <django.dispatch.dispatcher.Signal object>

Signal sent when a SkillPlugin cannot retrieve its skill, or the retrieved skill is invalid.

A GitHub api token that GitHub rejects is reported here, with the HTTP status in the error.

Parameters:
  • plugin – The SkillPlugin instance.

  • url – The skill source URL.

  • error – What went wrong. It never contains the GitHub api token.

  • duration – The seconds until the retrieval failed.

Example:

skill_plugin_retrieval_failed.send(sender=self.__class__, plugin=self, url=url, error="SKILL.md was not found", duration=0.3)
smarter.apps.llmtool.signals.skill.skill_plugin_retrieval_started = <django.dispatch.dispatcher.Signal object>

Signal sent when a SkillPlugin begins to retrieve its skill from the manifest’s skillData.source, which happens when the manifest is applied.

Parameters:
  • plugin – The SkillPlugin instance.

  • url – The skill source URL.

Example:

skill_plugin_retrieval_started.send(sender=self.__class__, plugin=self, url=url)
smarter.apps.llmtool.signals.skill.skill_plugin_retrieved = <django.dispatch.dispatcher.Signal object>

Signal sent when a SkillPlugin has retrieved its skill.

Parameters:
  • plugin – The SkillPlugin instance.

  • url – The skill source URL.

  • skill_name – The skill’s name, from its SKILL.md.

  • resource_count – The number of bundled files.

  • duration – The seconds that the retrieval took.

Example:

skill_plugin_retrieved.send(sender=self.__class__, plugin=self, url=url, skill_name="pdf", resource_count=4, duration=1.2)