def state_from_documents(results: Sequence[environment_pb2.Document],
                         max_title_tokens: int, max_context_tokens: int) -> str:
  """Produces a string representation of the search results.

  Args:
    results: A number of documents to be included in the state
    max_title_tokens: Maximum number of tokens from the title per document.
    max_context_tokens: Maximum number of tokens from the context per document.

  Returns:
    state: A flat string representation of the documents.
  """
  state = []
  for result in results:
    answer, answer_with_context = types.HistoryEntry.get_window_around_substr(
        result.content, result.answer.answer, max_context_tokens)
    state.append(f"Answer: '{answer}'.")
    if max_title_tokens > 0:
      title = " ".join(result.title.split()[:max_title_tokens])
      state.append(f"Title: '{title}'.")
    state.append(f"Result: '{answer_with_context}'.")
  return " ".join(state)
Produces a string representation of the search results.

  Args:
    results: A number of documents to be included in the state
    max_title_tokens: Maximum number of tokens from the title per document.
    max_context_tokens: Maximum number of tokens from the context per document.

  Returns:
    state: A flat string representation of the documents.
  
language/search_agents/t5/t5_agent_lib.py